@bitgo-beta/sdk-coin-sol 7.6.4-beta.723 → 7.6.4-beta.725

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.
Files changed (32) hide show
  1. package/dist/cjs/src/lib/index.d.ts +1 -0
  2. package/dist/cjs/src/lib/index.d.ts.map +1 -1
  3. package/dist/cjs/src/lib/index.js +5 -2
  4. package/dist/cjs/src/lib/serialization/compileTransactionMessage.d.ts +6 -0
  5. package/dist/cjs/src/lib/serialization/compileTransactionMessage.d.ts.map +1 -1
  6. package/dist/cjs/src/lib/serialization/compileTransactionMessage.js +7 -1
  7. package/dist/cjs/src/lib/transaction.d.ts.map +1 -1
  8. package/dist/cjs/src/lib/transaction.js +14 -1
  9. package/dist/cjs/src/lib/v1TransactionBuilder.d.ts +197 -0
  10. package/dist/cjs/src/lib/v1TransactionBuilder.d.ts.map +1 -0
  11. package/dist/cjs/src/lib/v1TransactionBuilder.js +436 -0
  12. package/dist/cjs/src/sol.d.ts.map +1 -1
  13. package/dist/cjs/src/sol.js +18 -6
  14. package/dist/cjs/test/unit/sol.js +221 -1
  15. package/dist/cjs/test/unit/transactionBuilder/v1TransactionBuilder.d.ts +2 -0
  16. package/dist/cjs/test/unit/transactionBuilder/v1TransactionBuilder.d.ts.map +1 -0
  17. package/dist/cjs/test/unit/transactionBuilder/v1TransactionBuilder.js +220 -0
  18. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  19. package/dist/esm/lib/index.d.ts +1 -0
  20. package/dist/esm/lib/index.d.ts.map +1 -1
  21. package/dist/esm/lib/index.js +2 -1
  22. package/dist/esm/lib/serialization/compileTransactionMessage.d.ts +6 -0
  23. package/dist/esm/lib/serialization/compileTransactionMessage.d.ts.map +1 -1
  24. package/dist/esm/lib/serialization/compileTransactionMessage.js +7 -1
  25. package/dist/esm/lib/transaction.d.ts.map +1 -1
  26. package/dist/esm/lib/transaction.js +14 -1
  27. package/dist/esm/lib/v1TransactionBuilder.d.ts +197 -0
  28. package/dist/esm/lib/v1TransactionBuilder.d.ts.map +1 -0
  29. package/dist/esm/lib/v1TransactionBuilder.js +428 -0
  30. package/dist/esm/sol.d.ts.map +1 -1
  31. package/dist/esm/sol.js +18 -6
  32. package/package.json +7 -7
@@ -0,0 +1,197 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { BaseCoin as CoinConfig } from '@bitgo-beta/statics';
3
+ import { BaseAddress, BaseKey, BaseTransactionBuilder, FeeOptions, PublicKey as BasePublicKey, SolV1TransactionConfig, TransactionType } from '@bitgo-beta/sdk-core';
4
+ import { TransactionInstruction } from '@solana/web3.js';
5
+ import { Transaction } from './transaction';
6
+ import { InstructionParams, Nonce } from './iface';
7
+ /**
8
+ * Construct an AdvanceNonceAccount instruction for a durable nonce.
9
+ *
10
+ * The v0 path receives this instruction from web3.js / the Rust wasm core
11
+ * (`NonceSource` durable variant); the v1 path compiles via
12
+ * `compileTransactionMessage`, so the nonce instruction must be constructed in
13
+ * TypeScript and injected into the compile input. The nonce authority
14
+ * (`authWalletAddress`) MUST sign the instruction — it becomes a required
15
+ * signer of the compiled message.
16
+ *
17
+ * @param nonceAddress - the durable nonce account address
18
+ * @param authWalletAddress - the nonce authority (gas-tank root in BitGo's model)
19
+ * @returns the AdvanceNonceAccount instruction
20
+ */
21
+ export declare function buildAdvanceNonceAccountInstruction(nonceAddress: string, authWalletAddress: string): TransactionInstruction;
22
+ /**
23
+ * Base builder for Solana v1 (SIMD-0296/0385) transactions.
24
+ *
25
+ * Parallel to the v0 {@link TransactionBuilder}, which is bound to a
26
+ * `@solana/web3.js` v0 `Transaction` and cannot emit a v1 wire. This builder
27
+ * owns the v1 assembly:
28
+ *
29
+ * - intent-to-instruction derivation via the shared `solInstructionFactory`
30
+ * (same `InstructionParams` representation as the v0 flows)
31
+ * - durable nonce: `AdvanceNonceAccount` instruction injection (first) plus the
32
+ * nonce hash in the blockhash field
33
+ * - transaction config (compute unit limit, heap size, loaded accounts data
34
+ * size limit, priority fee as total lamports)
35
+ * - signer management: private-key signers (`sign`) and external signatures
36
+ * (`addSignature`), assembled in message-signer order
37
+ * - message compile via `compileTransactionMessage` and signed wire via
38
+ * `serializeWireTransaction`
39
+ *
40
+ * Signature assembly is in message-signer order (fee payer first, then the
41
+ * remaining signers in the compiled account order), NOT insertion order —
42
+ * required for multi-signer v1 transactions such as durable-nonce CT
43
+ * (user + gas-tank nonce authority). Missing signatures are zero-filled in
44
+ * their slots so the wire shape stays valid for partial-sign flows; the
45
+ * broadcastable wire is only produced once every required signer has a
46
+ * signature.
47
+ */
48
+ export declare abstract class V1TransactionBuilder extends BaseTransactionBuilder {
49
+ protected _transaction: Transaction;
50
+ private _instructionsData;
51
+ private _extraInstructions;
52
+ private _signers;
53
+ private _signatures;
54
+ private _lamportsPerSignature;
55
+ protected _sender: string;
56
+ protected _feePayer?: string;
57
+ protected _recentBlockhash: string;
58
+ protected _nonceInfo?: Nonce;
59
+ protected _memo?: string;
60
+ protected _transactionConfig?: SolV1TransactionConfig;
61
+ /** Optional override for the zk-elgamal-proof program id (used by CT instruction builders) */
62
+ protected _zkProofProgramId?: string;
63
+ constructor(_coinConfig: Readonly<CoinConfig>);
64
+ /**
65
+ * The transaction type.
66
+ */
67
+ protected abstract get transactionType(): TransactionType;
68
+ /** @inheritdoc */
69
+ protected buildImplementation(): Promise<Transaction>;
70
+ /**
71
+ * Assemble the v1 transaction: derive instructions, inject the durable-nonce
72
+ * instruction when present, compile the message, and assemble the signed
73
+ * wire in message-signer order.
74
+ *
75
+ * @returns {Transaction} The built transaction holding the v1 message and wire bytes
76
+ */
77
+ private buildV1;
78
+ /** @inheritdoc */
79
+ protected fromImplementation(rawTransaction: string): Transaction;
80
+ /** @inheritdoc */
81
+ protected get transaction(): Transaction;
82
+ /** @inheritdoc */
83
+ protected set transaction(transaction: Transaction);
84
+ /** @inheritdoc */
85
+ protected signImplementation(key: BaseKey): Transaction;
86
+ /** @inheritDoc */
87
+ addSignature(publicKey: BasePublicKey, signature: Buffer): void;
88
+ /**
89
+ * Sets the sender of this transaction.
90
+ * This account will be responsible for paying transaction fees.
91
+ *
92
+ * @param {string} senderAddress the account that is sending this transaction
93
+ * @returns {V1TransactionBuilder} This transaction builder
94
+ */
95
+ sender(senderAddress: string): this;
96
+ /**
97
+ * Set the transaction nonce.
98
+ * Requires both optional params in order to use the durable nonce.
99
+ *
100
+ * @param {string} blockHash The latest blockHash or the durable nonce hash
101
+ * @param {DurableNonceParams} [durableNonceParams] An object containing the walletNonceAddress and the authWalletAddress (required for durable nonce)
102
+ * @returns {V1TransactionBuilder} This transaction builder
103
+ */
104
+ nonce(blockHash: string, durableNonceParams?: {
105
+ walletNonceAddress: string;
106
+ authWalletAddress: string;
107
+ }): this;
108
+ /**
109
+ * Set the intent instructions to build, using the shared instruction params
110
+ * representation consumed by `solInstructionFactory` (same as the v0 flows).
111
+ *
112
+ * @param {InstructionParams[]} instructions the instruction params
113
+ * @returns {V1TransactionBuilder} This transaction builder
114
+ */
115
+ instructions(instructions: InstructionParams[]): this;
116
+ /**
117
+ * Append a pre-built instruction (e.g. an envelope-derived instruction or a
118
+ * custom instruction) to the transaction.
119
+ *
120
+ * @param {TransactionInstruction} instruction the instruction to append
121
+ * @returns {V1TransactionBuilder} This transaction builder
122
+ */
123
+ addInstruction(instruction: TransactionInstruction): this;
124
+ /**
125
+ * Set the v1 transaction config (compute unit limit, heap size, loaded
126
+ * accounts data size limit, and priority fee as total lamports). Required
127
+ * before building.
128
+ *
129
+ * @param {SolV1TransactionConfig} config the v1 transaction config
130
+ * @returns {V1TransactionBuilder} This transaction builder
131
+ */
132
+ transactionConfig(config: SolV1TransactionConfig): this;
133
+ /**
134
+ * Set the priority fee (total lamports) on the v1 transaction config.
135
+ *
136
+ * @param {FeeOptions} feeOptions the priority fee
137
+ * @returns {V1TransactionBuilder} This transaction builder
138
+ */
139
+ setPriorityFee(feeOptions: FeeOptions): this;
140
+ /**
141
+ * Set the fee (lamports per signature) for fee estimation.
142
+ *
143
+ * @param {FeeOptions} feeOptions the fee
144
+ * @returns {V1TransactionBuilder} This transaction builder
145
+ */
146
+ fee(feeOptions: FeeOptions): this;
147
+ feePayer(feePayer: string): this;
148
+ /**
149
+ * Set the memo.
150
+ *
151
+ * @param {string} memo
152
+ * @returns {V1TransactionBuilder} This transaction builder
153
+ */
154
+ memo(memo: string): this;
155
+ /**
156
+ * Override the zk-elgamal-proof program id.
157
+ *
158
+ * Defaults to the canonical on-chain program id (`ZkE1Gama1Proof111...`)
159
+ * which is the same across mainnet, devnet, and testnet. Override only
160
+ * when targeting a custom deployment.
161
+ *
162
+ * @param {string} programId base58 encoded program id
163
+ * @returns {V1TransactionBuilder} This transaction builder
164
+ */
165
+ zkProofProgramId(programId: string): this;
166
+ /** @inheritdoc */
167
+ validateAddress(address: BaseAddress, addressFormat?: string): void;
168
+ /** @inheritdoc */
169
+ validateKey(key: BaseKey): void;
170
+ /** @inheritdoc */
171
+ validateRawTransaction(rawTransaction: string): void;
172
+ /** @inheritdoc */
173
+ validateTransaction(transaction?: Transaction): void;
174
+ /** @inheritdoc */
175
+ validateValue(value: BigNumber): void;
176
+ /**
177
+ * Validates the memo.
178
+ *
179
+ * @param {string} memo - the memo as string
180
+ */
181
+ validateMemo(memo: string): void;
182
+ /**
183
+ * Validates that the given key is not already in this._signers.
184
+ *
185
+ * @param {BaseKey} key - The key to check
186
+ */
187
+ private checkDuplicatedSigner;
188
+ /**
189
+ * Validates that the sender field is defined.
190
+ */
191
+ private validateSender;
192
+ /**
193
+ * Validates that the nonce field is defined.
194
+ */
195
+ private validateNonce;
196
+ }
197
+ //# sourceMappingURL=v1TransactionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1TransactionBuilder.d.ts","sourceRoot":"","sources":["../../../../src/lib/v1TransactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,qBAAqB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