@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.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Thru } from '@thru/thru-sdk/client';
|
|
1
2
|
import { Account } from '@thru/thru-sdk';
|
|
2
3
|
|
|
3
4
|
type AccountLookupContext = {
|
|
@@ -1121,17 +1122,17 @@ declare class TokenInstructionBuilder {
|
|
|
1121
1122
|
type TokenInstructionVariantName = (typeof TokenInstruction.payloadVariantDescriptors)[number]['name'];
|
|
1122
1123
|
declare function buildTokenInstructionBytes(variant: TokenInstructionVariantName, payload: Uint8Array): Uint8Array;
|
|
1123
1124
|
|
|
1124
|
-
declare function deriveMintAddress(mintAuthorityAddress: string, seed: string, tokenProgramAddress: string): {
|
|
1125
|
+
declare function deriveMintAddress(thru: Thru, mintAuthorityAddress: string, seed: string, tokenProgramAddress: string): {
|
|
1125
1126
|
address: string;
|
|
1126
1127
|
bytes: Uint8Array;
|
|
1127
1128
|
derivedSeed: Uint8Array;
|
|
1128
1129
|
};
|
|
1129
|
-
declare function deriveTokenAccountAddress(ownerAddress: string, mintAddress: string, tokenProgramAddress: string, seed?: Uint8Array): {
|
|
1130
|
+
declare function deriveTokenAccountAddress(thru: Thru, ownerAddress: string, mintAddress: string, tokenProgramAddress: string, seed?: Uint8Array): {
|
|
1130
1131
|
address: string;
|
|
1131
1132
|
bytes: Uint8Array;
|
|
1132
1133
|
derivedSeed: Uint8Array;
|
|
1133
1134
|
};
|
|
1134
|
-
declare function deriveWalletSeed(walletAddress: string, extraSeeds?: Uint8Array[]): Uint8Array;
|
|
1135
|
+
declare function deriveWalletSeed(thru: Thru, walletAddress: string, extraSeeds?: Uint8Array[]): Uint8Array;
|
|
1135
1136
|
|
|
1136
1137
|
declare function parseMintAccountData(account: Account): MintAccountInfo;
|
|
1137
1138
|
declare function parseTokenAccountData(account: Account): TokenAccountInfo;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Thru } from '@thru/thru-sdk/client';
|
|
1
2
|
import { Account } from '@thru/thru-sdk';
|
|
2
3
|
|
|
3
4
|
type AccountLookupContext = {
|
|
@@ -1121,17 +1122,17 @@ declare class TokenInstructionBuilder {
|
|
|
1121
1122
|
type TokenInstructionVariantName = (typeof TokenInstruction.payloadVariantDescriptors)[number]['name'];
|
|
1122
1123
|
declare function buildTokenInstructionBytes(variant: TokenInstructionVariantName, payload: Uint8Array): Uint8Array;
|
|
1123
1124
|
|
|
1124
|
-
declare function deriveMintAddress(mintAuthorityAddress: string, seed: string, tokenProgramAddress: string): {
|
|
1125
|
+
declare function deriveMintAddress(thru: Thru, mintAuthorityAddress: string, seed: string, tokenProgramAddress: string): {
|
|
1125
1126
|
address: string;
|
|
1126
1127
|
bytes: Uint8Array;
|
|
1127
1128
|
derivedSeed: Uint8Array;
|
|
1128
1129
|
};
|
|
1129
|
-
declare function deriveTokenAccountAddress(ownerAddress: string, mintAddress: string, tokenProgramAddress: string, seed?: Uint8Array): {
|
|
1130
|
+
declare function deriveTokenAccountAddress(thru: Thru, ownerAddress: string, mintAddress: string, tokenProgramAddress: string, seed?: Uint8Array): {
|
|
1130
1131
|
address: string;
|
|
1131
1132
|
bytes: Uint8Array;
|
|
1132
1133
|
derivedSeed: Uint8Array;
|
|
1133
1134
|
};
|
|
1134
|
-
declare function deriveWalletSeed(walletAddress: string, extraSeeds?: Uint8Array[]): Uint8Array;
|
|
1135
|
+
declare function deriveWalletSeed(thru: Thru, walletAddress: string, extraSeeds?: Uint8Array[]): Uint8Array;
|
|
1135
1136
|
|
|
1136
1137
|
declare function parseMintAccountData(account: Account): MintAccountInfo;
|
|
1137
1138
|
declare function parseTokenAccountData(account: Account): TokenAccountInfo;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pubkey as Pubkey$1
|
|
1
|
+
import { Pubkey as Pubkey$1 } from '@thru/thru-sdk';
|
|
2
2
|
import { encodeAddress } from '@thru/helpers';
|
|
3
3
|
|
|
4
4
|
// src/constants.ts
|
|
@@ -6975,12 +6975,12 @@ function createTransferInstruction(args) {
|
|
|
6975
6975
|
};
|
|
6976
6976
|
}
|
|
6977
6977
|
var TOKEN_ACCOUNT_DEFAULT_SEED = new Uint8Array(PUBKEY_LENGTH);
|
|
6978
|
-
function deriveMintAddress(mintAuthorityAddress, seed, tokenProgramAddress) {
|
|
6978
|
+
function deriveMintAddress(thru, mintAuthorityAddress, seed, tokenProgramAddress) {
|
|
6979
6979
|
const mintAuthorityBytes = Pubkey$1.from(mintAuthorityAddress).toBytes();
|
|
6980
6980
|
const seedBytes = hexToBytes2(seed);
|
|
6981
6981
|
if (seedBytes.length !== 32) throw new Error("Seed must be 32 bytes (64 hex characters)");
|
|
6982
|
-
const { bytes: derivedSeed } = deriveAddress([mintAuthorityBytes, seedBytes]);
|
|
6983
|
-
const result = deriveProgramAddress({
|
|
6982
|
+
const { bytes: derivedSeed } = thru.helpers.deriveAddress([mintAuthorityBytes, seedBytes]);
|
|
6983
|
+
const result = thru.helpers.deriveProgramAddress({
|
|
6984
6984
|
programAddress: tokenProgramAddress,
|
|
6985
6985
|
seed: derivedSeed,
|
|
6986
6986
|
ephemeral: false
|
|
@@ -6991,12 +6991,12 @@ function deriveMintAddress(mintAuthorityAddress, seed, tokenProgramAddress) {
|
|
|
6991
6991
|
derivedSeed
|
|
6992
6992
|
};
|
|
6993
6993
|
}
|
|
6994
|
-
function deriveTokenAccountAddress(ownerAddress, mintAddress, tokenProgramAddress, seed = TOKEN_ACCOUNT_DEFAULT_SEED) {
|
|
6994
|
+
function deriveTokenAccountAddress(thru, ownerAddress, mintAddress, tokenProgramAddress, seed = TOKEN_ACCOUNT_DEFAULT_SEED) {
|
|
6995
6995
|
if (seed.length !== PUBKEY_LENGTH) throw new Error("Token account seed must be 32 bytes");
|
|
6996
6996
|
const ownerBytes = Pubkey$1.from(ownerAddress).toBytes();
|
|
6997
6997
|
const mintBytes = Pubkey$1.from(mintAddress).toBytes();
|
|
6998
|
-
const { bytes: derivedSeed } = deriveAddress([ownerBytes, mintBytes, seed]);
|
|
6999
|
-
const result = deriveProgramAddress({
|
|
6998
|
+
const { bytes: derivedSeed } = thru.helpers.deriveAddress([ownerBytes, mintBytes, seed]);
|
|
6999
|
+
const result = thru.helpers.deriveProgramAddress({
|
|
7000
7000
|
programAddress: tokenProgramAddress,
|
|
7001
7001
|
seed: derivedSeed,
|
|
7002
7002
|
ephemeral: false
|
|
@@ -7007,9 +7007,9 @@ function deriveTokenAccountAddress(ownerAddress, mintAddress, tokenProgramAddres
|
|
|
7007
7007
|
derivedSeed
|
|
7008
7008
|
};
|
|
7009
7009
|
}
|
|
7010
|
-
function deriveWalletSeed(walletAddress, extraSeeds = []) {
|
|
7010
|
+
function deriveWalletSeed(thru, walletAddress, extraSeeds = []) {
|
|
7011
7011
|
const walletBytes = Pubkey$1.from(walletAddress).toBytes();
|
|
7012
|
-
return deriveAddress([walletBytes, ...extraSeeds]).bytes;
|
|
7012
|
+
return thru.helpers.deriveAddress([walletBytes, ...extraSeeds]).bytes;
|
|
7013
7013
|
}
|
|
7014
7014
|
function hexToBytes2(hex) {
|
|
7015
7015
|
const normalized = hex.startsWith("0x") ? hex.slice(2) : hex;
|