@thru/token-program 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/derivation.ts +10 -6
package/dist/index.cjs
CHANGED
|
@@ -6977,12 +6977,12 @@ function createTransferInstruction(args) {
|
|
|
6977
6977
|
};
|
|
6978
6978
|
}
|
|
6979
6979
|
var TOKEN_ACCOUNT_DEFAULT_SEED = new Uint8Array(PUBKEY_LENGTH);
|
|
6980
|
-
function deriveMintAddress(mintAuthorityAddress, seed, tokenProgramAddress) {
|
|
6980
|
+
function deriveMintAddress(thru, mintAuthorityAddress, seed, tokenProgramAddress) {
|
|
6981
6981
|
const mintAuthorityBytes = thruSdk.Pubkey.from(mintAuthorityAddress).toBytes();
|
|
6982
6982
|
const seedBytes = hexToBytes2(seed);
|
|
6983
6983
|
if (seedBytes.length !== 32) throw new Error("Seed must be 32 bytes (64 hex characters)");
|
|
6984
|
-
const { bytes: derivedSeed } =
|
|
6985
|
-
const result =
|
|
6984
|
+
const { bytes: derivedSeed } = thru.helpers.deriveAddress([mintAuthorityBytes, seedBytes]);
|
|
6985
|
+
const result = thru.helpers.deriveProgramAddress({
|
|
6986
6986
|
programAddress: tokenProgramAddress,
|
|
6987
6987
|
seed: derivedSeed,
|
|
6988
6988
|
ephemeral: false
|
|
@@ -6993,12 +6993,12 @@ function deriveMintAddress(mintAuthorityAddress, seed, tokenProgramAddress) {
|
|
|
6993
6993
|
derivedSeed
|
|
6994
6994
|
};
|
|
6995
6995
|
}
|
|
6996
|
-
function deriveTokenAccountAddress(ownerAddress, mintAddress, tokenProgramAddress, seed = TOKEN_ACCOUNT_DEFAULT_SEED) {
|
|
6996
|
+
function deriveTokenAccountAddress(thru, ownerAddress, mintAddress, tokenProgramAddress, seed = TOKEN_ACCOUNT_DEFAULT_SEED) {
|
|
6997
6997
|
if (seed.length !== PUBKEY_LENGTH) throw new Error("Token account seed must be 32 bytes");
|
|
6998
6998
|
const ownerBytes = thruSdk.Pubkey.from(ownerAddress).toBytes();
|
|
6999
6999
|
const mintBytes = thruSdk.Pubkey.from(mintAddress).toBytes();
|
|
7000
|
-
const { bytes: derivedSeed } =
|
|
7001
|
-
const result =
|
|
7000
|
+
const { bytes: derivedSeed } = thru.helpers.deriveAddress([ownerBytes, mintBytes, seed]);
|
|
7001
|
+
const result = thru.helpers.deriveProgramAddress({
|
|
7002
7002
|
programAddress: tokenProgramAddress,
|
|
7003
7003
|
seed: derivedSeed,
|
|
7004
7004
|
ephemeral: false
|
|
@@ -7009,9 +7009,9 @@ function deriveTokenAccountAddress(ownerAddress, mintAddress, tokenProgramAddres
|
|
|
7009
7009
|
derivedSeed
|
|
7010
7010
|
};
|
|
7011
7011
|
}
|
|
7012
|
-
function deriveWalletSeed(walletAddress, extraSeeds = []) {
|
|
7012
|
+
function deriveWalletSeed(thru, walletAddress, extraSeeds = []) {
|
|
7013
7013
|
const walletBytes = thruSdk.Pubkey.from(walletAddress).toBytes();
|
|
7014
|
-
return
|
|
7014
|
+
return thru.helpers.deriveAddress([walletBytes, ...extraSeeds]).bytes;
|
|
7015
7015
|
}
|
|
7016
7016
|
function hexToBytes2(hex) {
|
|
7017
7017
|
const normalized = hex.startsWith("0x") ? hex.slice(2) : hex;
|