@atomiqlabs/chain-solana 12.0.14 → 13.0.9
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/LICENSE +201 -201
- package/dist/index.d.ts +12 -29
- package/dist/index.js +32 -45
- package/dist/solana/SolanaChainType.d.ts +15 -11
- package/dist/solana/SolanaChainType.js +2 -2
- package/dist/solana/SolanaChains.d.ts +9 -20
- package/dist/solana/SolanaChains.js +25 -25
- package/dist/solana/SolanaInitializer.d.ts +38 -18
- package/dist/solana/SolanaInitializer.js +75 -63
- package/dist/solana/btcrelay/SolanaBtcRelay.d.ts +230 -228
- package/dist/solana/btcrelay/SolanaBtcRelay.js +463 -441
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.d.ts +33 -29
- package/dist/solana/btcrelay/headers/SolanaBtcHeader.js +37 -34
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.d.ts +50 -46
- package/dist/solana/btcrelay/headers/SolanaBtcStoredHeader.js +81 -78
- package/dist/solana/btcrelay/program/programIdl.json +671 -671
- package/dist/solana/chain/SolanaAction.d.ts +26 -26
- package/dist/solana/chain/SolanaAction.js +86 -86
- package/dist/solana/chain/SolanaChainInterface.d.ts +77 -65
- package/dist/solana/chain/SolanaChainInterface.js +138 -125
- package/dist/solana/chain/SolanaModule.d.ts +14 -14
- package/dist/solana/chain/SolanaModule.js +13 -13
- package/dist/solana/chain/modules/SolanaAddresses.d.ts +8 -8
- package/dist/solana/chain/modules/SolanaAddresses.js +22 -22
- package/dist/solana/chain/modules/SolanaBlocks.d.ts +32 -28
- package/dist/solana/chain/modules/SolanaBlocks.js +76 -72
- package/dist/solana/chain/modules/SolanaEvents.d.ts +68 -68
- package/dist/solana/chain/modules/SolanaEvents.js +238 -238
- package/dist/solana/chain/modules/SolanaFees.d.ts +122 -121
- package/dist/solana/chain/modules/SolanaFees.js +381 -379
- package/dist/solana/chain/modules/SolanaSignatures.d.ts +24 -23
- package/dist/solana/chain/modules/SolanaSignatures.js +39 -39
- package/dist/solana/chain/modules/SolanaSlots.d.ts +31 -31
- package/dist/solana/chain/modules/SolanaSlots.js +69 -68
- package/dist/solana/chain/modules/SolanaTokens.d.ts +123 -136
- package/dist/solana/chain/modules/SolanaTokens.js +242 -248
- package/dist/solana/chain/modules/SolanaTransactions.d.ts +139 -124
- package/dist/solana/chain/modules/SolanaTransactions.js +404 -323
- package/dist/solana/events/SolanaChainEvents.d.ts +35 -88
- package/dist/solana/events/SolanaChainEvents.js +92 -256
- package/dist/solana/events/SolanaChainEventsBrowser.d.ts +128 -75
- package/dist/solana/events/SolanaChainEventsBrowser.js +337 -172
- package/dist/solana/program/SolanaProgramBase.d.ts +45 -40
- package/dist/solana/program/SolanaProgramBase.js +43 -43
- package/dist/solana/program/SolanaProgramModule.d.ts +8 -8
- package/dist/solana/program/SolanaProgramModule.js +11 -11
- package/dist/solana/program/modules/SolanaProgramEvents.d.ts +53 -53
- package/dist/solana/program/modules/SolanaProgramEvents.js +117 -114
- package/dist/solana/swaps/SolanaSwapData.d.ts +102 -71
- package/dist/solana/swaps/SolanaSwapData.js +335 -292
- package/dist/solana/swaps/SolanaSwapModule.d.ts +10 -10
- package/dist/solana/swaps/SolanaSwapModule.js +12 -11
- package/dist/solana/swaps/SolanaSwapProgram.d.ts +202 -224
- package/dist/solana/swaps/SolanaSwapProgram.js +587 -570
- package/dist/solana/swaps/SwapTypeEnum.d.ts +11 -11
- package/dist/solana/swaps/SwapTypeEnum.js +43 -42
- package/dist/solana/swaps/modules/SolanaDataAccount.d.ts +95 -94
- package/dist/solana/swaps/modules/SolanaDataAccount.js +230 -231
- package/dist/solana/swaps/modules/SolanaLpVault.d.ts +69 -71
- package/dist/solana/swaps/modules/SolanaLpVault.js +171 -173
- package/dist/solana/swaps/modules/SwapClaim.d.ts +126 -129
- package/dist/solana/swaps/modules/SwapClaim.js +292 -291
- package/dist/solana/swaps/modules/SwapInit.d.ts +208 -217
- package/dist/solana/swaps/modules/SwapInit.js +521 -519
- package/dist/solana/swaps/modules/SwapRefund.d.ts +81 -82
- package/dist/solana/swaps/modules/SwapRefund.js +277 -262
- package/dist/solana/swaps/programIdl.json +945 -945
- package/dist/solana/swaps/programTypes.d.ts +943 -943
- package/dist/solana/swaps/programTypes.js +945 -945
- package/dist/solana/wallet/SolanaKeypairWallet.d.ts +13 -9
- package/dist/solana/wallet/SolanaKeypairWallet.js +37 -33
- package/dist/solana/wallet/SolanaSigner.d.ts +15 -11
- package/dist/solana/wallet/SolanaSigner.js +21 -17
- package/dist/utils/Utils.d.ts +58 -53
- package/dist/utils/Utils.js +170 -170
- package/package.json +44 -41
- package/src/index.ts +17 -36
- package/src/solana/SolanaChainType.ts +32 -27
- package/src/solana/SolanaChains.ts +23 -23
- package/src/solana/SolanaInitializer.ts +126 -102
- package/src/solana/btcrelay/SolanaBtcRelay.ts +618 -589
- package/src/solana/btcrelay/headers/SolanaBtcHeader.ts +60 -57
- package/src/solana/btcrelay/headers/SolanaBtcStoredHeader.ts +105 -102
- package/src/solana/btcrelay/program/programIdl.json +670 -670
- package/src/solana/chain/SolanaAction.ts +108 -108
- package/src/solana/chain/SolanaChainInterface.ts +219 -192
- package/src/solana/chain/SolanaModule.ts +20 -20
- package/src/solana/chain/modules/SolanaAddresses.ts +20 -20
- package/src/solana/chain/modules/SolanaBlocks.ts +83 -78
- package/src/solana/chain/modules/SolanaEvents.ts +271 -270
- package/src/solana/chain/modules/SolanaFees.ts +454 -450
- package/src/solana/chain/modules/SolanaSignatures.ts +39 -39
- package/src/solana/chain/modules/SolanaSlots.ts +83 -82
- package/src/solana/chain/modules/SolanaTokens.ts +300 -307
- package/src/solana/chain/modules/SolanaTransactions.ts +452 -365
- package/src/solana/events/SolanaChainEvents.ts +110 -299
- package/src/solana/events/SolanaChainEventsBrowser.ts +399 -209
- package/src/solana/program/SolanaProgramBase.ts +79 -79
- package/src/solana/program/SolanaProgramModule.ts +15 -15
- package/src/solana/program/modules/SolanaProgramEvents.ts +157 -155
- package/src/solana/swaps/SolanaSwapData.ts +420 -430
- package/src/solana/swaps/SolanaSwapModule.ts +17 -16
- package/src/solana/swaps/SolanaSwapProgram.ts +858 -854
- package/src/solana/swaps/SwapTypeEnum.ts +30 -29
- package/src/solana/swaps/modules/SolanaDataAccount.ts +300 -307
- package/src/solana/swaps/modules/SolanaLpVault.ts +208 -215
- package/src/solana/swaps/modules/SwapClaim.ts +385 -389
- package/src/solana/swaps/modules/SwapInit.ts +657 -663
- package/src/solana/swaps/modules/SwapRefund.ts +335 -323
- package/src/solana/swaps/programIdl.json +944 -944
- package/src/solana/swaps/programTypes.ts +1885 -1885
- package/src/solana/wallet/SolanaKeypairWallet.ts +40 -36
- package/src/solana/wallet/SolanaSigner.ts +28 -24
- package/src/utils/Utils.ts +194 -180
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { PublicKey, Signer, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import { SolanaTx } from "./modules/SolanaTransactions";
|
|
3
|
-
import { SolanaChainInterface } from "./SolanaChainInterface";
|
|
4
|
-
export declare class SolanaAction {
|
|
5
|
-
computeBudget: number;
|
|
6
|
-
readonly mainSigner: PublicKey;
|
|
7
|
-
private readonly root;
|
|
8
|
-
private readonly instructions;
|
|
9
|
-
private feeRate
|
|
10
|
-
private readonly signers;
|
|
11
|
-
private firstIxBeforeComputeBudget;
|
|
12
|
-
constructor(mainSigner: PublicKey, root: SolanaChainInterface, instructions?: TransactionInstruction[] | TransactionInstruction, computeBudget?: number, feeRate?: string, signers?: Signer[], firstIxBeforeComputeBudget?: boolean);
|
|
13
|
-
private estimateFee;
|
|
14
|
-
addIx(instruction: TransactionInstruction, computeBudget?: number, signers?: Signer[]): void;
|
|
15
|
-
add(action: SolanaAction): this;
|
|
16
|
-
addAction(action: SolanaAction, index?: number): this;
|
|
17
|
-
tx(feeRate?: string, block?: {
|
|
18
|
-
blockhash: string;
|
|
19
|
-
blockHeight: number;
|
|
20
|
-
}): Promise<SolanaTx>;
|
|
21
|
-
addToTxs(txs: SolanaTx[], feeRate?: string, block?: {
|
|
22
|
-
blockhash: string;
|
|
23
|
-
blockHeight: number;
|
|
24
|
-
}): Promise<void>;
|
|
25
|
-
ixsLength(): number;
|
|
26
|
-
}
|
|
1
|
+
import { PublicKey, Signer, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import { SolanaTx } from "./modules/SolanaTransactions";
|
|
3
|
+
import { SolanaChainInterface } from "./SolanaChainInterface";
|
|
4
|
+
export declare class SolanaAction {
|
|
5
|
+
computeBudget: number | null;
|
|
6
|
+
readonly mainSigner: PublicKey;
|
|
7
|
+
private readonly root;
|
|
8
|
+
private readonly instructions;
|
|
9
|
+
private feeRate?;
|
|
10
|
+
private readonly signers;
|
|
11
|
+
private firstIxBeforeComputeBudget;
|
|
12
|
+
constructor(mainSigner: PublicKey, root: SolanaChainInterface, instructions?: TransactionInstruction[] | TransactionInstruction, computeBudget?: number, feeRate?: string, signers?: Signer[], firstIxBeforeComputeBudget?: boolean);
|
|
13
|
+
private estimateFee;
|
|
14
|
+
addIx(instruction: TransactionInstruction, computeBudget?: number, signers?: Signer[]): void;
|
|
15
|
+
add(action: SolanaAction): this;
|
|
16
|
+
addAction(action: SolanaAction, index?: number): this;
|
|
17
|
+
tx(feeRate?: string, block?: {
|
|
18
|
+
blockhash: string;
|
|
19
|
+
blockHeight: number;
|
|
20
|
+
}): Promise<SolanaTx>;
|
|
21
|
+
addToTxs(txs: SolanaTx[], feeRate?: string, block?: {
|
|
22
|
+
blockhash: string;
|
|
23
|
+
blockHeight: number;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
ixsLength(): number;
|
|
26
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SolanaAction = void 0;
|
|
4
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
-
class SolanaAction {
|
|
6
|
-
constructor(mainSigner, root, instructions = [], computeBudget = 0, feeRate, signers, firstIxBeforeComputeBudget) {
|
|
7
|
-
this.firstIxBeforeComputeBudget = false;
|
|
8
|
-
this.mainSigner = mainSigner;
|
|
9
|
-
this.root = root;
|
|
10
|
-
this.instructions = Array.isArray(instructions) ? instructions : [instructions];
|
|
11
|
-
this.computeBudget = computeBudget;
|
|
12
|
-
this.feeRate = feeRate;
|
|
13
|
-
this.signers = signers || [];
|
|
14
|
-
if (firstIxBeforeComputeBudget != null)
|
|
15
|
-
this.firstIxBeforeComputeBudget = firstIxBeforeComputeBudget;
|
|
16
|
-
}
|
|
17
|
-
estimateFee() {
|
|
18
|
-
const mutableAccounts = [];
|
|
19
|
-
this.instructions.forEach(ix => ix.keys.forEach(key => key.isWritable && mutableAccounts.push(key.pubkey)));
|
|
20
|
-
return this.root.Fees.getFeeRate(mutableAccounts);
|
|
21
|
-
}
|
|
22
|
-
addIx(instruction, computeBudget, signers) {
|
|
23
|
-
this.instructions.push(instruction);
|
|
24
|
-
if (this.computeBudget == null) {
|
|
25
|
-
this.computeBudget = computeBudget;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
if (computeBudget != null)
|
|
29
|
-
this.computeBudget += computeBudget;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
add(action) {
|
|
33
|
-
return this.addAction(action);
|
|
34
|
-
}
|
|
35
|
-
addAction(action, index = this.instructions.length) {
|
|
36
|
-
if (action.firstIxBeforeComputeBudget) {
|
|
37
|
-
if (this.instructions.length > 0)
|
|
38
|
-
throw new Error("Tried to add firstIxBeforeComputeBudget action to existing action with instructions");
|
|
39
|
-
this.firstIxBeforeComputeBudget = true;
|
|
40
|
-
}
|
|
41
|
-
if (this.firstIxBeforeComputeBudget && this.instructions.length > 0 && index === 0)
|
|
42
|
-
throw new Error("Tried adding to firstIxBeforeComputeBudget action on 0th index");
|
|
43
|
-
if (!action.mainSigner.equals(this.mainSigner))
|
|
44
|
-
throw new Error("Actions need to have the same signer!");
|
|
45
|
-
if (this.computeBudget == null && action.computeBudget != null)
|
|
46
|
-
this.computeBudget = action.computeBudget;
|
|
47
|
-
if (this.computeBudget != null && action.computeBudget != null)
|
|
48
|
-
this.computeBudget += action.computeBudget;
|
|
49
|
-
this.instructions.splice(index, 0, ...action.instructions);
|
|
50
|
-
this.signers.push(...action.signers);
|
|
51
|
-
if (this.feeRate == null)
|
|
52
|
-
this.feeRate = action.feeRate;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
async tx(feeRate, block) {
|
|
56
|
-
const tx = new web3_js_1.Transaction();
|
|
57
|
-
tx.feePayer = this.mainSigner;
|
|
58
|
-
if (feeRate == null)
|
|
59
|
-
feeRate = this.feeRate;
|
|
60
|
-
if (feeRate == null)
|
|
61
|
-
feeRate = await this.estimateFee();
|
|
62
|
-
let instructions = this.instructions;
|
|
63
|
-
if (instructions.length > 0 && this.firstIxBeforeComputeBudget) {
|
|
64
|
-
tx.add(this.instructions[0]);
|
|
65
|
-
instructions = this.instructions.slice(1);
|
|
66
|
-
}
|
|
67
|
-
this.root.Fees.applyFeeRateBegin(tx, this.computeBudget, feeRate);
|
|
68
|
-
instructions.forEach(ix => tx.add(ix));
|
|
69
|
-
this.root.Fees.applyFeeRateEnd(tx, this.computeBudget, feeRate);
|
|
70
|
-
if (block != null) {
|
|
71
|
-
tx.recentBlockhash = block.blockhash;
|
|
72
|
-
tx.lastValidBlockHeight = block.blockHeight + this.root.TX_SLOT_VALIDITY;
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
tx,
|
|
76
|
-
signers: this.signers
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
async addToTxs(txs, feeRate, block) {
|
|
80
|
-
txs.push(await this.tx(feeRate, block));
|
|
81
|
-
}
|
|
82
|
-
ixsLength() {
|
|
83
|
-
return this.instructions.length;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.SolanaAction = SolanaAction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolanaAction = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
class SolanaAction {
|
|
6
|
+
constructor(mainSigner, root, instructions = [], computeBudget = 0, feeRate, signers, firstIxBeforeComputeBudget) {
|
|
7
|
+
this.firstIxBeforeComputeBudget = false;
|
|
8
|
+
this.mainSigner = mainSigner;
|
|
9
|
+
this.root = root;
|
|
10
|
+
this.instructions = Array.isArray(instructions) ? instructions : [instructions];
|
|
11
|
+
this.computeBudget = computeBudget;
|
|
12
|
+
this.feeRate = feeRate;
|
|
13
|
+
this.signers = signers || [];
|
|
14
|
+
if (firstIxBeforeComputeBudget != null)
|
|
15
|
+
this.firstIxBeforeComputeBudget = firstIxBeforeComputeBudget;
|
|
16
|
+
}
|
|
17
|
+
estimateFee() {
|
|
18
|
+
const mutableAccounts = [];
|
|
19
|
+
this.instructions.forEach(ix => ix.keys.forEach(key => key.isWritable && mutableAccounts.push(key.pubkey)));
|
|
20
|
+
return this.root.Fees.getFeeRate(mutableAccounts);
|
|
21
|
+
}
|
|
22
|
+
addIx(instruction, computeBudget, signers) {
|
|
23
|
+
this.instructions.push(instruction);
|
|
24
|
+
if (this.computeBudget == null) {
|
|
25
|
+
this.computeBudget = computeBudget ?? null;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
if (computeBudget != null)
|
|
29
|
+
this.computeBudget += computeBudget;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
add(action) {
|
|
33
|
+
return this.addAction(action);
|
|
34
|
+
}
|
|
35
|
+
addAction(action, index = this.instructions.length) {
|
|
36
|
+
if (action.firstIxBeforeComputeBudget) {
|
|
37
|
+
if (this.instructions.length > 0)
|
|
38
|
+
throw new Error("Tried to add firstIxBeforeComputeBudget action to existing action with instructions");
|
|
39
|
+
this.firstIxBeforeComputeBudget = true;
|
|
40
|
+
}
|
|
41
|
+
if (this.firstIxBeforeComputeBudget && this.instructions.length > 0 && index === 0)
|
|
42
|
+
throw new Error("Tried adding to firstIxBeforeComputeBudget action on 0th index");
|
|
43
|
+
if (!action.mainSigner.equals(this.mainSigner))
|
|
44
|
+
throw new Error("Actions need to have the same signer!");
|
|
45
|
+
if (this.computeBudget == null && action.computeBudget != null)
|
|
46
|
+
this.computeBudget = action.computeBudget;
|
|
47
|
+
if (this.computeBudget != null && action.computeBudget != null)
|
|
48
|
+
this.computeBudget += action.computeBudget;
|
|
49
|
+
this.instructions.splice(index, 0, ...action.instructions);
|
|
50
|
+
this.signers.push(...action.signers);
|
|
51
|
+
if (this.feeRate == null)
|
|
52
|
+
this.feeRate = action.feeRate;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
async tx(feeRate, block) {
|
|
56
|
+
const tx = new web3_js_1.Transaction();
|
|
57
|
+
tx.feePayer = this.mainSigner;
|
|
58
|
+
if (feeRate == null)
|
|
59
|
+
feeRate = this.feeRate;
|
|
60
|
+
if (feeRate == null)
|
|
61
|
+
feeRate = await this.estimateFee();
|
|
62
|
+
let instructions = this.instructions;
|
|
63
|
+
if (instructions.length > 0 && this.firstIxBeforeComputeBudget) {
|
|
64
|
+
tx.add(this.instructions[0]);
|
|
65
|
+
instructions = this.instructions.slice(1);
|
|
66
|
+
}
|
|
67
|
+
this.root.Fees.applyFeeRateBegin(tx, this.computeBudget, feeRate);
|
|
68
|
+
instructions.forEach(ix => tx.add(ix));
|
|
69
|
+
this.root.Fees.applyFeeRateEnd(tx, this.computeBudget, feeRate);
|
|
70
|
+
if (block != null) {
|
|
71
|
+
tx.recentBlockhash = block.blockhash;
|
|
72
|
+
tx.lastValidBlockHeight = block.blockHeight + this.root.TX_SLOT_VALIDITY;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
tx,
|
|
76
|
+
signers: this.signers
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async addToTxs(txs, feeRate, block) {
|
|
80
|
+
txs.push(await this.tx(feeRate, block));
|
|
81
|
+
}
|
|
82
|
+
ixsLength() {
|
|
83
|
+
return this.instructions.length;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.SolanaAction = SolanaAction;
|
|
@@ -1,65 +1,77 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
32
|
-
readonly
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { Connection, SendOptions, Transaction } from "@solana/web3.js";
|
|
4
|
+
import { SolanaFees } from "./modules/SolanaFees";
|
|
5
|
+
import { SolanaBlocks } from "./modules/SolanaBlocks";
|
|
6
|
+
import { SolanaSlots } from "./modules/SolanaSlots";
|
|
7
|
+
import { SolanaTokens } from "./modules/SolanaTokens";
|
|
8
|
+
import { SignedSolanaTx, SolanaTransactions, SolanaTx } from "./modules/SolanaTransactions";
|
|
9
|
+
import { SolanaSignatures } from "./modules/SolanaSignatures";
|
|
10
|
+
import { SolanaEvents } from "./modules/SolanaEvents";
|
|
11
|
+
import { ChainInterface, TransactionConfirmationOptions } from "@atomiqlabs/base";
|
|
12
|
+
import { SolanaSigner } from "../wallet/SolanaSigner";
|
|
13
|
+
import { Buffer } from "buffer";
|
|
14
|
+
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
|
|
15
|
+
/**
|
|
16
|
+
* Retry policy configuration for Solana RPC calls
|
|
17
|
+
* @category Chain Interface
|
|
18
|
+
*/
|
|
19
|
+
export type SolanaRetryPolicy = {
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
delay?: number;
|
|
22
|
+
exponential?: boolean;
|
|
23
|
+
transactionResendInterval?: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Main chain interface for interacting with Solana blockchain
|
|
27
|
+
* @category Chain Interface
|
|
28
|
+
*/
|
|
29
|
+
export declare class SolanaChainInterface implements ChainInterface<SolanaTx, SignedSolanaTx, SolanaSigner, "SOLANA", Wallet> {
|
|
30
|
+
readonly chainId = "SOLANA";
|
|
31
|
+
readonly SLOT_TIME = 400;
|
|
32
|
+
readonly TX_SLOT_VALIDITY = 151;
|
|
33
|
+
readonly connection: Connection;
|
|
34
|
+
readonly retryPolicy?: SolanaRetryPolicy;
|
|
35
|
+
readonly Blocks: SolanaBlocks;
|
|
36
|
+
Fees: SolanaFees;
|
|
37
|
+
readonly Slots: SolanaSlots;
|
|
38
|
+
readonly Tokens: SolanaTokens;
|
|
39
|
+
readonly Transactions: SolanaTransactions;
|
|
40
|
+
readonly Signatures: SolanaSignatures;
|
|
41
|
+
readonly Events: SolanaEvents;
|
|
42
|
+
protected readonly logger: {
|
|
43
|
+
debug: (msg: string, ...args: any[]) => false | void;
|
|
44
|
+
info: (msg: string, ...args: any[]) => false | void;
|
|
45
|
+
warn: (msg: string, ...args: any[]) => false | void;
|
|
46
|
+
error: (msg: string, ...args: any[]) => false | void;
|
|
47
|
+
};
|
|
48
|
+
constructor(connection: Connection, retryPolicy?: SolanaRetryPolicy, solanaFeeEstimator?: SolanaFees);
|
|
49
|
+
getBalance(signer: string, tokenAddress: string): Promise<bigint>;
|
|
50
|
+
isValidAddress(address: string): boolean;
|
|
51
|
+
normalizeAddress(address: string): string;
|
|
52
|
+
getNativeCurrencyAddress(): string;
|
|
53
|
+
txsTransfer(signer: string, token: string, amount: bigint, dstAddress: string, feeRate?: string): Promise<SolanaTx[]>;
|
|
54
|
+
transfer(signer: SolanaSigner, token: string, amount: bigint, dstAddress: string, txOptions?: TransactionConfirmationOptions): Promise<string>;
|
|
55
|
+
sendAndConfirm(signer: SolanaSigner, txs: SolanaTx[], waitForConfirmation?: boolean, abortSignal?: AbortSignal, parallel?: boolean, onBeforePublish?: (txId: string, rawTx: string) => Promise<void>): Promise<string[]>;
|
|
56
|
+
sendSignedAndConfirm(txs: SignedSolanaTx[], waitForConfirmation?: boolean, abortSignal?: AbortSignal, parallel?: boolean, onBeforePublish?: (txId: string, rawTx: string) => Promise<void>): Promise<string[]>;
|
|
57
|
+
serializeTx(tx: SolanaTx): Promise<string>;
|
|
58
|
+
deserializeTx(txData: string): Promise<SolanaTx>;
|
|
59
|
+
serializeSignedTx(tx: Transaction): Promise<string>;
|
|
60
|
+
deserializeSignedTx(txData: string): Promise<Transaction>;
|
|
61
|
+
getTxIdStatus(txId: string): Promise<"not_found" | "pending" | "success" | "reverted">;
|
|
62
|
+
getTxStatus(tx: string): Promise<"not_found" | "pending" | "success" | "reverted">;
|
|
63
|
+
getFinalizedBlock(): Promise<{
|
|
64
|
+
height: number;
|
|
65
|
+
blockHash: string;
|
|
66
|
+
}>;
|
|
67
|
+
offBeforeTxReplace(callback: (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => Promise<void>): boolean;
|
|
68
|
+
onBeforeTxReplace(callback: (oldTx: string, oldTxId: string, newTx: string, newTxId: string) => Promise<void>): void;
|
|
69
|
+
onBeforeTxSigned(callback: (tx: SolanaTx) => Promise<void>): void;
|
|
70
|
+
offBeforeTxSigned(callback: (tx: SolanaTx) => Promise<void>): boolean;
|
|
71
|
+
onSendTransaction(callback: (tx: Buffer, options?: SendOptions) => Promise<string>): void;
|
|
72
|
+
offSendTransaction(callback: (tx: Buffer, options?: SendOptions) => Promise<string>): boolean;
|
|
73
|
+
isValidToken(tokenIdentifier: string): boolean;
|
|
74
|
+
randomAddress(): string;
|
|
75
|
+
randomSigner(): SolanaSigner;
|
|
76
|
+
wrapSigner(signer: Wallet): Promise<SolanaSigner>;
|
|
77
|
+
}
|