-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: implement ogmiosToCore certificates mapping
feat(core): add addressNetworkId and createRewardAccount utils BREAKING CHANGE: rename block types - CompactBlock -> BlockInfo - Block -> ExtendedBlockInfo BREAKING CHANGE: hoist ogmiosToCore to ogmios package
- Loading branch information
1 parent
10d1f2b
commit aef2e8d
Showing
24 changed files
with
599 additions
and
226 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Address, Ed25519KeyHash, NetworkId, RewardAccount } from '../Cardano'; | ||
import { CML } from './CML'; | ||
import { parseCmlAddress } from './parseCmlAddress'; | ||
import { usingAutoFree } from '@cardano-sdk/util'; | ||
|
||
export const addressNetworkId = (address: RewardAccount | Address): NetworkId => | ||
usingAutoFree((scope) => parseCmlAddress(scope, address.toString())!.network_id()); | ||
|
||
export const createRewardAccount = (stakeKeyHash: Ed25519KeyHash, networkId: NetworkId) => | ||
usingAutoFree((scope) => { | ||
const keyHash = scope.manage(CML.Ed25519KeyHash.from_hex(stakeKeyHash.toString())); | ||
const stakeCredential = scope.manage(CML.StakeCredential.from_keyhash(keyHash)); | ||
const rewardAccount = scope.manage(CML.RewardAddress.new(networkId, stakeCredential)); | ||
return RewardAccount(scope.manage(rewardAccount.to_address()).to_bech32()); | ||
}); |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Cardano, addressNetworkId, createRewardAccount } from '../../src'; | ||
|
||
describe('address', () => { | ||
describe('addressNetworkId', () => { | ||
it('parses testnet address', () => { | ||
expect(addressNetworkId(Cardano.Address('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t'))).toBe( | ||
Cardano.NetworkId.testnet | ||
); | ||
}); | ||
|
||
it('parses testnet reward account', () => { | ||
expect( | ||
addressNetworkId(Cardano.RewardAccount('stake_test1urpklgzqsh9yqz8pkyuxcw9dlszpe5flnxjtl55epla6ftqktdyfz')) | ||
).toBe(Cardano.NetworkId.testnet); | ||
}); | ||
|
||
it('parses mainnet address', () => { | ||
expect( | ||
addressNetworkId( | ||
Cardano.Address( | ||
'addr1qx52knza2h5x090n4a5r7yraz3pwcamk9ppvuh7e26nfks7pnmhxqavtqy02zezklh27jt9r6z62sav3mugappdc7xnskxy2pn' | ||
) | ||
) | ||
).toBe(Cardano.NetworkId.mainnet); | ||
}); | ||
|
||
it('parses mainnet reward account', () => { | ||
expect( | ||
addressNetworkId(Cardano.RewardAccount('stake1u89sasnfyjtmgk8ydqfv3fdl52f36x3djedfnzfc9rkgzrcss5vgr')) | ||
).toBe(Cardano.NetworkId.mainnet); | ||
}); | ||
|
||
it('parses mainnet byron address', () => { | ||
expect( | ||
addressNetworkId( | ||
Cardano.Address( | ||
'DdzFFzCqrht4PWfBGtmrQz4x1GkZHYLVGbK7aaBkjWxujxzz3L5GxCgPiTsks5RjUr3yX9KvwKjNJBt7ZzPCmS3fUQrGeRvo9Y1YBQKQ' | ||
) | ||
) | ||
).toBe(Cardano.NetworkId.mainnet); | ||
}); | ||
}); | ||
|
||
describe('createRewardAccount', () => { | ||
const keyHash = Cardano.Ed25519KeyHash('f15db05f56035465bf8900a09bdaa16c3d8b8244fea686524408dd80'); | ||
|
||
it('creates a mainnet address', () => { | ||
const rewardAccount = createRewardAccount(keyHash, Cardano.NetworkId.mainnet); | ||
expect(rewardAccount.startsWith('stake')).toBe(true); | ||
expect(rewardAccount.startsWith('stake_test')).toBe(false); | ||
}); | ||
|
||
it('creates a testnet address', () => { | ||
const rewardAccount = createRewardAccount(keyHash, Cardano.NetworkId.testnet); | ||
expect(rewardAccount.startsWith('stake_test')).toBe(true); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './Provider'; | ||
export * from './CardanoNode'; | ||
export * from './util'; | ||
export * as ogmiosToCore from './ogmiosToCore'; | ||
export * as Ogmios from '@cardano-ogmios/client'; |
Oops, something went wrong.