-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into abi-upgrades
- Loading branch information
Showing
16 changed files
with
382 additions
and
72 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./Ed25519Account"; | ||
export * from "./Account"; | ||
export * from "./SingleKeyAccount"; | ||
export * from "./utils"; |
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,39 @@ | ||
import { sha3_256 } from "@noble/hashes/sha3"; | ||
import { AccountAddress } from "../../accountAddress"; | ||
import { DeriveScheme } from "../../../types"; | ||
|
||
/** | ||
* Creates an object address from creator address and seed | ||
* | ||
* @param creatorAddress The object creator account address | ||
* @param seed The seed in either Uint8Array | string type | ||
* | ||
* @returns The object account address | ||
*/ | ||
export const createObjectAddress = (creatorAddress: AccountAddress, seed: Uint8Array | string): AccountAddress => { | ||
const creatorBytes = creatorAddress.bcsToBytes(); | ||
|
||
const seedBytes = typeof seed === "string" ? Buffer.from(seed, "utf8") : seed; | ||
|
||
const bytes = new Uint8Array([...creatorBytes, ...seedBytes, DeriveScheme.DeriveObjectAddressFromSeed]); | ||
|
||
return new AccountAddress(sha3_256(bytes)); | ||
}; | ||
|
||
/** | ||
* Creates a token object address from creator address, collection name and token name | ||
* | ||
* @param creatorAddress The token creator account address | ||
* @param collectionName The collection name | ||
* @param tokenName The token name | ||
* | ||
* @returns The token account address | ||
*/ | ||
export const createTokenAddress = ( | ||
creatorAddress: AccountAddress, | ||
collectionName: string, | ||
tokenName: string, | ||
): AccountAddress => { | ||
const seed = `${collectionName}::${tokenName}`; | ||
return createObjectAddress(creatorAddress, seed); | ||
}; |
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 @@ | ||
export * from "./address"; |
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.