-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: delegation distribution portfolio is now persisted on chain an…
…d taken into account during change distribution BREAKING CHANGES: - TxBuilder delegatePortfolio now takes a full Cip17DelegationPortfolio object rather than a list of pools
- Loading branch information
1 parent
948d377
commit 7573938
Showing
14 changed files
with
672 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
packages/core/test/Cardano/types/DelegationAndRewards.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import * as Cardano from '../../../src/Cardano'; | ||
|
||
describe('portfolioMetadataFromCip17', () => { | ||
const poolIds: Cardano.PoolId[] = [ | ||
Cardano.PoolId('pool1zuevzm3xlrhmwjw87ec38mzs02tlkwec9wxpgafcaykmwg7efhh'), | ||
Cardano.PoolId('pool1t9xlrjyk76c96jltaspgwcnulq6pdkmhnge8xgza8ku7qvpsy9r'), | ||
Cardano.PoolId('pool1la4ghj4w4f8p4yk4qmx0qvqmzv6592ee9rs0vgla5w6lc2nc8w5') | ||
]; | ||
|
||
const portfolio = { | ||
// eslint-disable-next-line sonarjs/no-duplicate-string | ||
name: 'Tests Portfolio', | ||
pools: [ | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[0])), | ||
name: 'A', | ||
ticker: 'At', | ||
weight: 1 | ||
}, | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[1])), | ||
name: 'B', | ||
ticker: 'Bt', | ||
weight: 1 | ||
}, | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[2])), | ||
name: 'C', | ||
ticker: 'Ct', | ||
weight: 1 | ||
} | ||
] | ||
}; | ||
|
||
it('can get portfolio metadata from CIP-17', () => { | ||
const portfolioMetadata = Cardano.portfolioMetadataFromCip17(portfolio); | ||
|
||
expect(portfolioMetadata).toEqual({ | ||
name: 'Tests Portfolio', | ||
pools: [ | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[0])), | ||
weight: 1 | ||
}, | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[1])), | ||
weight: 1 | ||
}, | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[2])), | ||
weight: 1 | ||
} | ||
] | ||
}); | ||
}); | ||
|
||
it('can get portfolio metadata from CIP-17', () => { | ||
const metadatum: Cardano.Metadatum = new Map<Cardano.Metadatum, Cardano.Metadatum>([ | ||
['name', 'Tests Portfolio'], | ||
[ | ||
'pools', | ||
[ | ||
new Map<Cardano.Metadatum, Cardano.Metadatum>([ | ||
['id', Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[0]))], | ||
['weight', 1n] | ||
]), | ||
new Map<Cardano.Metadatum, Cardano.Metadatum>([ | ||
['id', Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[1]))], | ||
['weight', 1n] | ||
]), | ||
new Map<Cardano.Metadatum, Cardano.Metadatum>([ | ||
['id', Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[2]))], | ||
['weight', 1n] | ||
]) | ||
] | ||
] | ||
]); | ||
|
||
const cip17 = Cardano.cip17FromMetadatum(metadatum); | ||
expect(cip17).toEqual({ | ||
name: 'Tests Portfolio', | ||
pools: [ | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[0])), | ||
weight: 1 | ||
}, | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[1])), | ||
weight: 1 | ||
}, | ||
{ | ||
id: Cardano.PoolIdHex(Cardano.PoolId.toKeyHash(poolIds[2])), | ||
weight: 1 | ||
} | ||
] | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.