@bitgo-beta/sdk-coin-flrp 1.0.1-beta.40 → 1.0.1-beta.400
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/src/flrp.d.ts +10 -17
- package/dist/src/flrp.d.ts.map +1 -1
- package/dist/src/flrp.js +51 -77
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -2
- package/dist/src/lib/ExportInCTxBuilder.d.ts +43 -0
- package/dist/src/lib/ExportInCTxBuilder.d.ts.map +1 -0
- package/dist/src/lib/ExportInCTxBuilder.js +150 -0
- package/dist/src/lib/ExportInPTxBuilder.d.ts +28 -0
- package/dist/src/lib/ExportInPTxBuilder.d.ts.map +1 -0
- package/dist/src/lib/ExportInPTxBuilder.js +174 -0
- package/dist/src/lib/ImportInCTxBuilder.d.ts +34 -0
- package/dist/src/lib/ImportInCTxBuilder.d.ts.map +1 -0
- package/dist/src/lib/ImportInCTxBuilder.js +175 -0
- package/dist/src/lib/ImportInPTxBuilder.d.ts +38 -0
- package/dist/src/lib/ImportInPTxBuilder.d.ts.map +1 -0
- package/dist/src/lib/ImportInPTxBuilder.js +208 -0
- package/dist/src/lib/atomicInCTransactionBuilder.d.ts +12 -16
- package/dist/src/lib/atomicInCTransactionBuilder.d.ts.map +1 -1
- package/dist/src/lib/atomicInCTransactionBuilder.js +30 -41
- package/dist/src/lib/atomicTransactionBuilder.d.ts +97 -69
- package/dist/src/lib/atomicTransactionBuilder.d.ts.map +1 -1
- package/dist/src/lib/atomicTransactionBuilder.js +217 -210
- package/dist/src/lib/iface.d.ts +65 -57
- package/dist/src/lib/iface.d.ts.map +1 -1
- package/dist/src/lib/iface.js +20 -14
- package/dist/src/lib/index.d.ts +5 -0
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +12 -2
- package/dist/src/lib/keyPair.d.ts +5 -5
- package/dist/src/lib/keyPair.d.ts.map +1 -1
- package/dist/src/lib/keyPair.js +17 -9
- package/dist/src/lib/permissionlessValidatorTxBuilder.d.ts +41 -0
- package/dist/src/lib/permissionlessValidatorTxBuilder.d.ts.map +1 -0
- package/dist/src/lib/permissionlessValidatorTxBuilder.js +126 -0
- package/dist/src/lib/transaction.d.ts +30 -66
- package/dist/src/lib/transaction.d.ts.map +1 -1
- package/dist/src/lib/transaction.js +338 -199
- package/dist/src/lib/transactionBuilder.d.ts +115 -0
- package/dist/src/lib/transactionBuilder.d.ts.map +1 -0
- package/dist/src/lib/transactionBuilder.js +228 -0
- package/dist/src/lib/transactionBuilderFactory.d.ts +50 -30
- package/dist/src/lib/transactionBuilderFactory.d.ts.map +1 -1
- package/dist/src/lib/transactionBuilderFactory.js +129 -72
- package/dist/src/lib/utils.d.ts +125 -146
- package/dist/src/lib/utils.d.ts.map +1 -1
- package/dist/src/lib/utils.js +338 -321
- package/dist/test/resources/account.d.ts +81 -0
- package/dist/test/resources/account.d.ts.map +1 -0
- package/dist/test/resources/account.js +79 -0
- package/dist/test/resources/transactionData/exportInC.d.ts +50 -0
- package/dist/test/resources/transactionData/exportInC.d.ts.map +1 -0
- package/dist/test/resources/transactionData/exportInC.js +58 -0
- package/dist/test/resources/transactionData/exportInP.d.ts +60 -0
- package/dist/test/resources/transactionData/exportInP.d.ts.map +1 -0
- package/dist/test/resources/transactionData/exportInP.js +101 -0
- package/dist/test/resources/transactionData/importInC.d.ts +56 -0
- package/dist/test/resources/transactionData/importInC.d.ts.map +1 -0
- package/dist/test/resources/transactionData/importInC.js +120 -0
- package/dist/test/resources/transactionData/importInP.d.ts +66 -0
- package/dist/test/resources/transactionData/importInP.d.ts.map +1 -0
- package/dist/test/resources/transactionData/importInP.js +84 -0
- package/dist/test/unit/flrp.js +449 -68
- package/dist/test/unit/lib/exportInCTxBuilder.d.ts +2 -0
- package/dist/test/unit/lib/exportInCTxBuilder.d.ts.map +1 -0
- package/dist/test/unit/lib/exportInCTxBuilder.js +193 -0
- package/dist/test/unit/lib/exportInPTxBuilder.d.ts +2 -0
- package/dist/test/unit/lib/exportInPTxBuilder.d.ts.map +1 -0
- package/dist/test/unit/lib/exportInPTxBuilder.js +296 -0
- package/dist/test/unit/lib/importInCTxBuilder.d.ts +2 -0
- package/dist/test/unit/lib/importInCTxBuilder.d.ts.map +1 -0
- package/dist/test/unit/lib/importInCTxBuilder.js +309 -0
- package/dist/test/unit/lib/importInPTxBuilder.d.ts +2 -0
- package/dist/test/unit/lib/importInPTxBuilder.d.ts.map +1 -0
- package/dist/test/unit/lib/importInPTxBuilder.js +490 -0
- package/dist/test/unit/lib/keyPair.d.ts +2 -0
- package/dist/test/unit/lib/keyPair.d.ts.map +1 -0
- package/dist/test/unit/lib/keyPair.js +158 -0
- package/dist/test/unit/lib/signFlowTestSuit.d.ts +20 -0
- package/dist/test/unit/lib/signFlowTestSuit.d.ts.map +1 -0
- package/dist/test/unit/lib/signFlowTestSuit.js +83 -0
- package/dist/test/unit/lib/signatureIndex.d.ts +13 -0
- package/dist/test/unit/lib/signatureIndex.d.ts.map +1 -0
- package/dist/test/unit/lib/signatureIndex.js +843 -0
- package/dist/test/unit/lib/transactionBuilderFactory.d.ts +2 -0
- package/dist/test/unit/lib/transactionBuilderFactory.d.ts.map +1 -0
- package/dist/test/unit/lib/transactionBuilderFactory.js +60 -0
- package/dist/test/unit/lib/utils.js +681 -206
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -11
- package/.eslintignore +0 -5
- package/.eslintrc.json +0 -7
- package/.mocharc.yml +0 -8
- package/CHANGELOG.md +0 -0
- package/dist/src/iface.d.ts +0 -25
- package/dist/src/iface.d.ts.map +0 -1
- package/dist/src/iface.js +0 -3
- package/dist/src/lib/constants.d.ts +0 -11
- package/dist/src/lib/constants.d.ts.map +0 -1
- package/dist/src/lib/constants.js +0 -17
- package/dist/src/lib/errors.d.ts +0 -8
- package/dist/src/lib/errors.d.ts.map +0 -1
- package/dist/src/lib/errors.js +0 -19
- package/dist/src/lib/exportInCTxBuilder.d.ts +0 -77
- package/dist/src/lib/exportInCTxBuilder.d.ts.map +0 -1
- package/dist/src/lib/exportInCTxBuilder.js +0 -170
- package/dist/src/lib/exportInPTxBuilder.d.ts +0 -30
- package/dist/src/lib/exportInPTxBuilder.d.ts.map +0 -1
- package/dist/src/lib/exportInPTxBuilder.js +0 -56
- package/dist/test/unit/lib/atomicTransactionBuilder.d.ts +0 -2
- package/dist/test/unit/lib/atomicTransactionBuilder.d.ts.map +0 -1
- package/dist/test/unit/lib/atomicTransactionBuilder.js +0 -222
- package/dist/test/unit/lib/exportTxBuilder.d.ts +0 -2
- package/dist/test/unit/lib/exportTxBuilder.d.ts.map +0 -1
- package/dist/test/unit/lib/exportTxBuilder.js +0 -45
- package/dist/test/unit/lib/transaction.d.ts +0 -2
- package/dist/test/unit/lib/transaction.d.ts.map +0 -1
- package/dist/test/unit/lib/transaction.js +0 -460
- package/dist/test/unit/smoke.d.ts +0 -2
- package/dist/test/unit/smoke.d.ts.map +0 -1
- package/dist/test/unit/smoke.js +0 -23
|
@@ -5,60 +5,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AtomicInCTransactionBuilder = void 0;
|
|
7
7
|
const atomicTransactionBuilder_1 = require("./atomicTransactionBuilder");
|
|
8
|
-
const utils_1 = __importDefault(require("./utils"));
|
|
9
8
|
const sdk_core_1 = require("@bitgo-beta/sdk-core");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* removing direct Avalanche SDK dependencies. Network / chain ids are expected to be provided
|
|
13
|
-
* in the transaction._network object by a higher-level factory once Flare network constants
|
|
14
|
-
* are finalized. For now we CB58-decode placeholders if present and default to zero buffers.
|
|
15
|
-
*/
|
|
9
|
+
const flarejs_1 = require("@flarenetwork/flarejs");
|
|
10
|
+
const utils_1 = __importDefault(require("./utils"));
|
|
16
11
|
class AtomicInCTransactionBuilder extends atomicTransactionBuilder_1.AtomicTransactionBuilder {
|
|
17
12
|
constructor(_coinConfig) {
|
|
18
13
|
super(_coinConfig);
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.initializeChainIds();
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Set base fee (already scaled to Flare C-chain native decimals). Accept bigint | number | string.
|
|
25
|
-
*/
|
|
26
|
-
feeRate(baseFee) {
|
|
27
|
-
const n = typeof baseFee === 'bigint' ? baseFee : BigInt(baseFee);
|
|
28
|
-
this.validateFee(n);
|
|
29
|
-
this.setFeeRate(n);
|
|
30
|
-
return this;
|
|
14
|
+
this._externalChainId = utils_1.default.cb58Decode(this.transaction._network.blockchainID);
|
|
15
|
+
this.transaction._blockchainID = Buffer.from(utils_1.default.cb58Decode(this.transaction._network.cChainBlockchainID)).toString('hex');
|
|
31
16
|
}
|
|
32
|
-
/**
|
|
33
|
-
* Recreate builder state from raw tx (hex). Flare C-chain support TBD; for now validate & stash.
|
|
34
|
-
*/
|
|
17
|
+
/** @inheritdoc */
|
|
35
18
|
fromImplementation(rawTransaction) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
19
|
+
const txBytes = new Uint8Array(Buffer.from(rawTransaction, 'hex'));
|
|
20
|
+
const codec = flarejs_1.avmSerial.getAVMManager().getDefaultCodec();
|
|
21
|
+
const [tx] = flarejs_1.evmSerial.ImportTx.fromBytes(txBytes, codec);
|
|
22
|
+
const addressMaps = this.transaction._fromAddresses.map((a) => new flarejs_1.utils.AddressMap([[new flarejs_1.Address(a), 0]]));
|
|
23
|
+
const unsignedTx = new flarejs_1.UnsignedTx(tx, [], new flarejs_1.utils.AddressMaps(addressMaps), []);
|
|
24
|
+
this.initBuilder(unsignedTx);
|
|
41
25
|
return this.transaction;
|
|
42
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Check that fee is greater than 0.
|
|
29
|
+
* @param {bigint} fee
|
|
30
|
+
*/
|
|
43
31
|
validateFee(fee) {
|
|
44
|
-
if (fee <=
|
|
32
|
+
if (fee <= BigInt(0)) {
|
|
45
33
|
throw new sdk_core_1.BuildTransactionError('Fee must be greater than 0');
|
|
46
34
|
}
|
|
47
35
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Initialize the transaction builder fields using the decoded transaction data
|
|
38
|
+
*
|
|
39
|
+
* @param {UnsignedTx} tx the transaction data
|
|
40
|
+
* @returns itself
|
|
41
|
+
*/
|
|
42
|
+
initBuilder(tx) {
|
|
43
|
+
// Validate network and blockchain IDs
|
|
44
|
+
const baseTx = tx.getTx();
|
|
45
|
+
if (baseTx.getBlockchainId() !== this.transaction._blockchainID) {
|
|
46
|
+
throw new Error('blockchain ID mismatch');
|
|
55
47
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const currentContainer = this.transaction;
|
|
59
|
-
const current = currentContainer._fee || { fee: '0' };
|
|
60
|
-
currentContainer._fee = { ...current, feeRate: n.toString() };
|
|
48
|
+
this.transaction.setTransaction(tx);
|
|
49
|
+
return this;
|
|
61
50
|
}
|
|
62
51
|
}
|
|
63
52
|
exports.AtomicInCTransactionBuilder = AtomicInCTransactionBuilder;
|
|
64
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXRvbWljSW5DVHJhbnNhY3Rpb25CdWlsZGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2xpYi9hdG9taWNJbkNUcmFuc2FjdGlvbkJ1aWxkZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7O0FBQUEseUVBQXNFO0FBRXRFLG1EQUE2RDtBQUM3RCxtREFBdUc7QUFDdkcsb0RBQTRCO0FBRzVCLE1BQXNCL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cmFuc2FjdGlvbiBkYXRhXG4gICAqIEByZXR1cm5zIGl0c2VsZlxuICAgKi9cbiAgaW5pdEJ1aWxkZXIodHg6IFVuc2lnbmVkVHgpOiB0aGlzIHtcbiAgICAvLyBWYWxpZGF0ZSBuZXR3b3JrIGFuZCBibG9ja2NoYWluIElEc1xuICAgIGNvbnN0IGJhc2VUeCA9IHR4LmdldFR4KCk7XG4gICAgaWYgKGJhc2VUeC5nZXRCbG9ja2NoYWluSWQoKSAhPT0gdGhpcy50cmFuc2FjdGlvbi5fYmxvY2tjaGFpbklEKSB7XG4gICAgICB0aHJvdyBuZXcgRXJyb3IoJ2Jsb2NrY2hhaW4gSUQgbWlzbWF0Y2gnKTtcbiAgICB9XG4gICAgdGhpcy50cmFuc2FjdGlvbi5zZXRUcmFuc2FjdGlvbih0eCk7XG4gICAgcmV0dXJuIHRoaXM7XG4gIH1cbn1cbiJdfQ==
|
|
@@ -1,93 +1,121 @@
|
|
|
1
1
|
import { BaseCoin as CoinConfig } from '@bitgo-beta/statics';
|
|
2
|
-
import { TransactionType
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
protected
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
_assetId: Buffer;
|
|
19
|
-
_fromAddresses: string[];
|
|
20
|
-
_to: string[];
|
|
21
|
-
_locktime: bigint;
|
|
22
|
-
_threshold: number;
|
|
23
|
-
_fee: {
|
|
24
|
-
fee: string;
|
|
25
|
-
feeRate?: string;
|
|
26
|
-
size?: number;
|
|
27
|
-
};
|
|
28
|
-
hasCredentials: boolean;
|
|
29
|
-
_tx?: unknown;
|
|
30
|
-
setTransaction: (tx: unknown) => void;
|
|
31
|
-
};
|
|
32
|
-
constructor(coinConfig: Readonly<CoinConfig>);
|
|
2
|
+
import { TransactionType } from '@bitgo-beta/sdk-core';
|
|
3
|
+
import { TransactionBuilder } from './transactionBuilder';
|
|
4
|
+
import { Transaction } from './transaction';
|
|
5
|
+
import { Credential, utils as FlareUtils } from '@flarenetwork/flarejs';
|
|
6
|
+
import { DecodedUtxoObj } from './iface';
|
|
7
|
+
import { FlrpFeeState } from '@bitgo/public-types';
|
|
8
|
+
export declare abstract class AtomicTransactionBuilder extends TransactionBuilder {
|
|
9
|
+
protected _externalChainId: Buffer;
|
|
10
|
+
protected recoverSigner: boolean;
|
|
11
|
+
constructor(_coinConfig: Readonly<CoinConfig>);
|
|
12
|
+
/** @inheritdoc */
|
|
13
|
+
protected buildImplementation(): Promise<Transaction>;
|
|
14
|
+
/**
|
|
15
|
+
* Builds the Flare transaction. Transaction field is changed.
|
|
16
|
+
*/
|
|
17
|
+
protected abstract buildFlareTransaction(): void | Promise<void>;
|
|
33
18
|
protected abstract get transactionType(): TransactionType;
|
|
34
|
-
validateAmount(amount: bigint): void;
|
|
35
19
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
20
|
+
* Fee is fix for AVM atomic tx.
|
|
21
|
+
*
|
|
22
|
+
* @returns network.txFee
|
|
23
|
+
* @protected
|
|
38
24
|
*/
|
|
39
|
-
protected
|
|
25
|
+
protected get fixedFee(): string;
|
|
40
26
|
/**
|
|
41
|
-
*
|
|
42
|
-
* Based on AVAX P-chain implementation adapted for FlareJS.
|
|
27
|
+
* Set the transaction type
|
|
43
28
|
*
|
|
44
|
-
*
|
|
45
|
-
|
|
29
|
+
* @param {TransactionType} transactionType The transaction type to be set
|
|
30
|
+
*/
|
|
31
|
+
setTransactionType(transactionType: TransactionType): void;
|
|
32
|
+
/**
|
|
33
|
+
* The internal chain is the one set for the coin in coinConfig.network. The external chain is the other chain involved.
|
|
34
|
+
* The external chain id is the source on import and the destination on export.
|
|
46
35
|
*
|
|
47
|
-
* @param
|
|
48
|
-
* @returns Object containing TransferableInput[], TransferableOutput[], and Credential[]
|
|
36
|
+
* @param {string} chainId - id of the external chain
|
|
49
37
|
*/
|
|
50
|
-
|
|
51
|
-
inputs: TransferableInput[];
|
|
52
|
-
outputs: TransferableOutput[];
|
|
53
|
-
credentials: Credential[];
|
|
54
|
-
};
|
|
38
|
+
externalChainId(chainId: string | Buffer): this;
|
|
55
39
|
/**
|
|
56
|
-
* Set
|
|
40
|
+
* Set the transaction fee
|
|
57
41
|
*
|
|
58
|
-
* @param
|
|
59
|
-
* @returns this builder instance for chaining
|
|
42
|
+
* @param {string | bigint} feeValue - the fee value
|
|
60
43
|
*/
|
|
61
|
-
|
|
44
|
+
fee(feeValue: string | bigint): this;
|
|
62
45
|
/**
|
|
63
|
-
*
|
|
64
|
-
* Creates a credential with the provided signatures
|
|
46
|
+
* Set the fee state for dynamic fee calculation (P-chain transactions)
|
|
65
47
|
*
|
|
66
|
-
* @param
|
|
67
|
-
* @param signatures - Array of signature hex strings or empty strings for placeholders
|
|
68
|
-
* @returns Credential instance
|
|
48
|
+
* @param {FlrpFeeState} state - the fee state from the network
|
|
69
49
|
*/
|
|
70
|
-
|
|
50
|
+
feeState(state: FlrpFeeState): this;
|
|
71
51
|
/**
|
|
72
|
-
*
|
|
52
|
+
* Set the amount for the transaction
|
|
53
|
+
*
|
|
54
|
+
* @param {bigint | string} value - the amount to transfer
|
|
73
55
|
*/
|
|
74
|
-
|
|
56
|
+
amount(value: bigint | string): this;
|
|
75
57
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
58
|
+
* Compute addressesIndex for UTXOs following AVAX P approach.
|
|
59
|
+
* addressesIndex[senderIdx] = position of sender[senderIdx] in UTXO's address list
|
|
60
|
+
*
|
|
61
|
+
* IMPORTANT: UTXO addresses are sorted lexicographically by byte value to match
|
|
62
|
+
* on-chain storage order. The API may return addresses in arbitrary order, but
|
|
63
|
+
* on-chain UTXOs always store addresses in sorted order.
|
|
64
|
+
*
|
|
65
|
+
* Example:
|
|
66
|
+
* A = user key, B = hsm key, C = backup key
|
|
67
|
+
* sender (bitgoAddresses) = [ A, B, C ]
|
|
68
|
+
* utxo.addresses (from API) = [ B, C, A ]
|
|
69
|
+
* sorted utxo.addresses = [ A, B, C ] (sorted by hex value)
|
|
70
|
+
* addressesIndex = [ 0, 1, 2 ]
|
|
71
|
+
* (sender[0]=A is at position 0 in sorted UTXO, sender[1]=B is at position 1, etc.)
|
|
72
|
+
*
|
|
73
|
+
* @protected
|
|
78
74
|
*/
|
|
79
|
-
|
|
80
|
-
key: string;
|
|
81
|
-
}): this;
|
|
75
|
+
protected computeAddressesIndex(): void;
|
|
82
76
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
77
|
+
* Compute addressesIndex from parsed transaction data.
|
|
78
|
+
* Similar to computeAddressesIndex() but used when parsing existing transactions
|
|
79
|
+
* via initBuilder().
|
|
80
|
+
*
|
|
81
|
+
* IMPORTANT: UTXO addresses are sorted lexicographically by byte value to match
|
|
82
|
+
* on-chain storage order, ensuring consistency with fresh builds.
|
|
83
|
+
*
|
|
84
|
+
* @protected
|
|
85
|
+
*/
|
|
86
|
+
protected computeAddressesIndexFromParsed(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Validate UTXOs have consistent addresses.
|
|
89
|
+
* Note: UTXO threshold can differ from transaction threshold - each UTXO has its own
|
|
90
|
+
* signature requirement based on how it was created (e.g., change outputs may have threshold=1).
|
|
91
|
+
* @protected
|
|
85
92
|
*/
|
|
86
|
-
|
|
93
|
+
protected validateUtxoAddresses(): void;
|
|
87
94
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
95
|
+
* Create credential with dynamic ordering based on addressesIndex from UTXO.
|
|
96
|
+
* Matches AVAX P behavior: signature order depends on UTXO address positions.
|
|
97
|
+
*
|
|
98
|
+
* addressesIndex[senderIdx] = utxoPosition tells us where each sender is in the UTXO.
|
|
99
|
+
* We create signature slots ordered by utxoPosition (smaller position = earlier slot).
|
|
100
|
+
*
|
|
101
|
+
* @param utxo - The UTXO to create credential for
|
|
102
|
+
* @param threshold - Number of signatures required for this specific UTXO
|
|
103
|
+
* @returns Credential with empty signatures ordered based on UTXO positions
|
|
104
|
+
* @protected
|
|
105
|
+
*/
|
|
106
|
+
protected createCredentialForUtxo(utxo: DecodedUtxoObj, threshold: number): Credential;
|
|
107
|
+
/**
|
|
108
|
+
* Create AddressMap based on addressesIndex following AVAX P approach.
|
|
109
|
+
* Maps each sender address to its signature slot based on UTXO position ordering.
|
|
110
|
+
*
|
|
111
|
+
* addressesIndex[senderIdx] = utxoPosition
|
|
112
|
+
* Signature slots are ordered by utxoPosition (smaller = earlier slot).
|
|
113
|
+
*
|
|
114
|
+
* @param utxo - The UTXO to create AddressMap for
|
|
115
|
+
* @param threshold - Number of signatures required for this specific UTXO
|
|
116
|
+
* @returns AddressMap that maps addresses to signature slots based on UTXO order
|
|
117
|
+
* @protected
|
|
90
118
|
*/
|
|
91
|
-
|
|
119
|
+
protected createAddressMapForUtxo(utxo: DecodedUtxoObj, threshold: number): FlareUtils.AddressMap;
|
|
92
120
|
}
|
|
93
121
|
//# sourceMappingURL=atomicTransactionBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomicTransactionBuilder.d.ts","sourceRoot":"","sources":["../../../src/lib/atomicTransactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAyB,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"atomicTransactionBuilder.d.ts","sourceRoot":"","sources":["../../../src/lib/atomicTransactionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAyB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UA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