@ledgerhq/coin-solana 0.35.0-nightly.8 → 0.35.0
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +28 -80
- package/lib/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +50 -0
- package/lib/__tests__/fixtures/helpers.fixture.d.ts +138 -0
- package/lib/__tests__/fixtures/helpers.fixture.d.ts.map +1 -0
- package/lib/__tests__/fixtures/helpers.fixture.js +124 -0
- package/lib/__tests__/fixtures/helpers.fixture.js.map +1 -0
- package/lib/__tests__/scan-accounts.test.d.ts +2 -0
- package/lib/__tests__/scan-accounts.test.d.ts.map +1 -0
- package/lib/__tests__/scan-accounts.test.js +426 -0
- package/lib/__tests__/scan-accounts.test.js.map +1 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.js +91 -0
- package/lib/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.js +147 -0
- package/lib/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
- package/lib/__tests__/unit/utils.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/utils.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/utils.unit.test.js +16 -0
- package/lib/__tests__/unit/utils.unit.test.js.map +1 -0
- package/lib/__tests__/unit/validator-app.unit.test.d.ts +2 -0
- package/lib/__tests__/unit/validator-app.unit.test.d.ts.map +1 -0
- package/lib/__tests__/unit/validator-app.unit.test.js +169 -0
- package/lib/__tests__/unit/validator-app.unit.test.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +4 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +870 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/buildTransaction.test.d.ts +2 -0
- package/lib/buildTransaction.test.d.ts.map +1 -0
- package/lib/buildTransaction.test.js +164 -0
- package/lib/buildTransaction.test.js.map +1 -0
- package/lib/cryptoAssetsStore.test.d.ts +2 -0
- package/lib/cryptoAssetsStore.test.d.ts.map +1 -0
- package/lib/cryptoAssetsStore.test.js +15 -0
- package/lib/cryptoAssetsStore.test.js.map +1 -0
- package/lib/network/chain/account/parser.d.ts +1 -1
- package/lib/network/chain/account/stake.d.ts +23 -23
- package/lib/network/chain/account/token.d.ts +7 -7
- package/lib/network/chain/instruction/stake/types.d.ts +8 -8
- package/lib/network/chain/instruction/system/types.d.ts +10 -10
- package/lib/network/chain/web3.integration.test.d.ts +2 -0
- package/lib/network/chain/web3.integration.test.d.ts.map +1 -0
- package/lib/network/chain/web3.integration.test.js +70 -0
- package/lib/network/chain/web3.integration.test.js.map +1 -0
- package/lib/offchainMessage/format.unit.test.d.ts +2 -0
- package/lib/offchainMessage/format.unit.test.d.ts.map +1 -0
- package/lib/offchainMessage/format.unit.test.js +124 -0
- package/lib/offchainMessage/format.unit.test.js.map +1 -0
- package/lib/preload.test.d.ts +2 -0
- package/lib/preload.test.d.ts.map +1 -0
- package/lib/preload.test.js +9 -0
- package/lib/preload.test.js.map +1 -0
- package/lib/prepareTransaction.d.ts.map +1 -1
- package/lib/prepareTransaction.js +0 -4
- package/lib/prepareTransaction.js.map +1 -1
- package/lib/prepareTransaction.test.d.ts +2 -0
- package/lib/prepareTransaction.test.d.ts.map +1 -0
- package/lib/prepareTransaction.test.js +139 -0
- package/lib/prepareTransaction.test.js.map +1 -0
- package/lib/signOperation.d.ts.map +1 -1
- package/lib/signOperation.js +0 -2
- package/lib/signOperation.js.map +1 -1
- package/lib/signOperation.test.d.ts +3 -0
- package/lib/signOperation.test.d.ts.map +1 -0
- package/lib/signOperation.test.js +139 -0
- package/lib/signOperation.test.js.map +1 -0
- package/lib/signer.d.ts +0 -1
- package/lib/signer.d.ts.map +1 -1
- package/lib/signer.js.map +1 -1
- package/lib/tests/preload.fixtures.d.ts +5 -0
- package/lib/tests/preload.fixtures.d.ts.map +1 -0
- package/lib/tests/preload.fixtures.js +28 -0
- package/lib/tests/preload.fixtures.js.map +1 -0
- package/lib/tests/preload.unit.test.d.ts +2 -0
- package/lib/tests/preload.unit.test.d.ts.map +1 -0
- package/lib/tests/preload.unit.test.js +175 -0
- package/lib/tests/preload.unit.test.js.map +1 -0
- package/lib/tests/stakes-bridge.unit.test.d.ts +2 -0
- package/lib/tests/stakes-bridge.unit.test.d.ts.map +1 -0
- package/lib/tests/stakes-bridge.unit.test.js +166 -0
- package/lib/tests/stakes-bridge.unit.test.js.map +1 -0
- package/lib/tests/test-onchain-data.fixture.d.ts +20 -0
- package/lib/tests/test-onchain-data.fixture.d.ts.map +1 -0
- package/lib/tests/test-onchain-data.fixture.js +34 -0
- package/lib/tests/test-onchain-data.fixture.js.map +1 -0
- package/lib/tests/tokens-bridge.unit.test.d.ts +2 -0
- package/lib/tests/tokens-bridge.unit.test.d.ts.map +1 -0
- package/lib/tests/tokens-bridge.unit.test.js +615 -0
- package/lib/tests/tokens-bridge.unit.test.js.map +1 -0
- package/lib/tx-fees.js +0 -2
- package/lib/tx-fees.js.map +1 -1
- package/lib/types.d.ts +1 -2
- package/lib/types.d.ts.map +1 -1
- package/lib-es/__fixtures__/solana-spl-epjfwdd5aufqssqem2qn1xzybapc8g4weggkzwytdt1v.json +50 -0
- package/lib-es/__tests__/fixtures/helpers.fixture.d.ts +138 -0
- package/lib-es/__tests__/fixtures/helpers.fixture.d.ts.map +1 -0
- package/lib-es/__tests__/fixtures/helpers.fixture.js +110 -0
- package/lib-es/__tests__/fixtures/helpers.fixture.js.map +1 -0
- package/lib-es/__tests__/scan-accounts.test.d.ts +2 -0
- package/lib-es/__tests__/scan-accounts.test.d.ts.map +1 -0
- package/lib-es/__tests__/scan-accounts.test.js +398 -0
- package/lib-es/__tests__/scan-accounts.test.js.map +1 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts +2 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.js +86 -0
- package/lib-es/__tests__/unit/hw-signMessage.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts +2 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.js +142 -0
- package/lib-es/__tests__/unit/nftResolvers.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/utils.unit.test.d.ts +2 -0
- package/lib-es/__tests__/unit/utils.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/utils.unit.test.js +14 -0
- package/lib-es/__tests__/unit/utils.unit.test.js.map +1 -0
- package/lib-es/__tests__/unit/validator-app.unit.test.d.ts +2 -0
- package/lib-es/__tests__/unit/validator-app.unit.test.d.ts.map +1 -0
- package/lib-es/__tests__/unit/validator-app.unit.test.js +144 -0
- package/lib-es/__tests__/unit/validator-app.unit.test.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +4 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +864 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/buildTransaction.test.d.ts +2 -0
- package/lib-es/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/buildTransaction.test.js +162 -0
- package/lib-es/buildTransaction.test.js.map +1 -0
- package/lib-es/cryptoAssetsStore.test.d.ts +2 -0
- package/lib-es/cryptoAssetsStore.test.d.ts.map +1 -0
- package/lib-es/cryptoAssetsStore.test.js +13 -0
- package/lib-es/cryptoAssetsStore.test.js.map +1 -0
- package/lib-es/network/chain/account/parser.d.ts +1 -1
- package/lib-es/network/chain/account/stake.d.ts +23 -23
- package/lib-es/network/chain/account/token.d.ts +7 -7
- package/lib-es/network/chain/instruction/stake/types.d.ts +8 -8
- package/lib-es/network/chain/instruction/system/types.d.ts +10 -10
- package/lib-es/network/chain/web3.integration.test.d.ts +2 -0
- package/lib-es/network/chain/web3.integration.test.d.ts.map +1 -0
- package/lib-es/network/chain/web3.integration.test.js +68 -0
- package/lib-es/network/chain/web3.integration.test.js.map +1 -0
- package/lib-es/offchainMessage/format.unit.test.d.ts +2 -0
- package/lib-es/offchainMessage/format.unit.test.d.ts.map +1 -0
- package/lib-es/offchainMessage/format.unit.test.js +122 -0
- package/lib-es/offchainMessage/format.unit.test.js.map +1 -0
- package/lib-es/preload.test.d.ts +2 -0
- package/lib-es/preload.test.d.ts.map +1 -0
- package/lib-es/preload.test.js +7 -0
- package/lib-es/preload.test.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -1
- package/lib-es/prepareTransaction.js +0 -4
- package/lib-es/prepareTransaction.js.map +1 -1
- package/lib-es/prepareTransaction.test.d.ts +2 -0
- package/lib-es/prepareTransaction.test.d.ts.map +1 -0
- package/lib-es/prepareTransaction.test.js +134 -0
- package/lib-es/prepareTransaction.test.js.map +1 -0
- package/lib-es/signOperation.d.ts.map +1 -1
- package/lib-es/signOperation.js +0 -2
- package/lib-es/signOperation.js.map +1 -1
- package/lib-es/signOperation.test.d.ts +3 -0
- package/lib-es/signOperation.test.d.ts.map +1 -0
- package/lib-es/signOperation.test.js +135 -0
- package/lib-es/signOperation.test.js.map +1 -0
- package/lib-es/signer.d.ts +0 -1
- package/lib-es/signer.d.ts.map +1 -1
- package/lib-es/signer.js.map +1 -1
- package/lib-es/tests/preload.fixtures.d.ts +5 -0
- package/lib-es/tests/preload.fixtures.d.ts.map +1 -0
- package/lib-es/tests/preload.fixtures.js +25 -0
- package/lib-es/tests/preload.fixtures.js.map +1 -0
- package/lib-es/tests/preload.unit.test.d.ts +2 -0
- package/lib-es/tests/preload.unit.test.d.ts.map +1 -0
- package/lib-es/tests/preload.unit.test.js +147 -0
- package/lib-es/tests/preload.unit.test.js.map +1 -0
- package/lib-es/tests/stakes-bridge.unit.test.d.ts +2 -0
- package/lib-es/tests/stakes-bridge.unit.test.d.ts.map +1 -0
- package/lib-es/tests/stakes-bridge.unit.test.js +161 -0
- package/lib-es/tests/stakes-bridge.unit.test.js.map +1 -0
- package/lib-es/tests/test-onchain-data.fixture.d.ts +20 -0
- package/lib-es/tests/test-onchain-data.fixture.d.ts.map +1 -0
- package/lib-es/tests/test-onchain-data.fixture.js +28 -0
- package/lib-es/tests/test-onchain-data.fixture.js.map +1 -0
- package/lib-es/tests/tokens-bridge.unit.test.d.ts +2 -0
- package/lib-es/tests/tokens-bridge.unit.test.d.ts.map +1 -0
- package/lib-es/tests/tokens-bridge.unit.test.js +610 -0
- package/lib-es/tests/tokens-bridge.unit.test.js.map +1 -0
- package/lib-es/tx-fees.js +0 -2
- package/lib-es/tx-fees.js.map +1 -1
- package/lib-es/types.d.ts +1 -2
- package/lib-es/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/prepareTransaction.ts +0 -4
- package/src/signOperation.ts +0 -2
- package/src/signer.ts +0 -1
- package/src/tests/preload.fixtures.ts +1 -1
- package/src/tx-fees.ts +0 -2
- package/src/types.ts +1 -2
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import scanAccounts1 from "./datasets/solana.scanAccounts.1";
|
|
3
|
+
import { AmountRequired, InvalidAddress, InvalidAddressBecauseDestinationIsAlsoSource, NotEnoughBalance, RecipientRequired, } from "@ledgerhq/errors";
|
|
4
|
+
import { SolanaAccountNotFunded, SolanaAddressOffEd25519, SolanaInvalidValidator, SolanaMemoIsTooLong, SolanaRecipientAssociatedTokenAccountWillBeFunded, SolanaStakeAccountNotFound, SolanaStakeAccountRequired, SolanaTokenAccountHoldsAnotherToken, SolanaValidatorRequired, } from "./errors";
|
|
5
|
+
import { encodeAccountIdWithTokenAccountAddress, MAX_MEMO_LENGTH } from "./logic";
|
|
6
|
+
import createTransaction from "./createTransaction";
|
|
7
|
+
import { compact } from "lodash/fp";
|
|
8
|
+
import { assertUnreachable } from "./utils";
|
|
9
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
10
|
+
import { encodeAccountId } from "@ledgerhq/coin-framework/lib/account/accountId";
|
|
11
|
+
import { testOnChainData } from "./tests/test-onchain-data.fixture";
|
|
12
|
+
import { getCryptoAssetsStore } from "./cryptoAssetsStore";
|
|
13
|
+
const mainAccId = encodeAccountId({
|
|
14
|
+
type: "js",
|
|
15
|
+
version: "2",
|
|
16
|
+
currencyId: "solana",
|
|
17
|
+
xpubOrAddress: testOnChainData.fundedSenderAddress,
|
|
18
|
+
derivationMode: "solanaMain",
|
|
19
|
+
});
|
|
20
|
+
const wSolSubAccId = encodeAccountIdWithTokenAccountAddress(mainAccId, testOnChainData.wSolSenderAssocTokenAccAddress);
|
|
21
|
+
const wSolToken = getCryptoAssetsStore().findTokenByAddressInCurrency("So11111111111111111111111111111111111111112", "solana");
|
|
22
|
+
const fees = (signatureCount) => new BigNumber(signatureCount * testOnChainData.fees.lamportsPerSignature);
|
|
23
|
+
const zero = new BigNumber(0);
|
|
24
|
+
const solana = {
|
|
25
|
+
scanAccounts: [scanAccounts1],
|
|
26
|
+
// FIXME Ordering of validators must be always the same, for this test to be stable:
|
|
27
|
+
// https://github.com/LedgerHQ/ledger-live-common/blob/develop/src/__tests__/test-helpers/bridge.ts#L171-L188
|
|
28
|
+
FIXME_ignorePreloadFields: ["validators", "splTokens"],
|
|
29
|
+
accounts: [
|
|
30
|
+
{
|
|
31
|
+
raw: makeAccount(testOnChainData.fundedSenderAddress),
|
|
32
|
+
/*
|
|
33
|
+
Solana integration is written in such a way that requires
|
|
34
|
+
prepareTransaction to be called before any meaningfull status
|
|
35
|
+
can be calculated. The general bridge tests do not run prepareTransaction
|
|
36
|
+
on all tests, so skip them in the general runner, but make alternatives for them.
|
|
37
|
+
*/
|
|
38
|
+
FIXME_tests: [
|
|
39
|
+
"balance is sum of ops",
|
|
40
|
+
"Default empty recipient have a recipientError",
|
|
41
|
+
"invalid recipient have a recipientError",
|
|
42
|
+
"can be called on an empty transaction",
|
|
43
|
+
],
|
|
44
|
+
transactions: [
|
|
45
|
+
...recipientRequired(),
|
|
46
|
+
...recipientNotValid(),
|
|
47
|
+
...recipientIsSameAsSender(),
|
|
48
|
+
...memoIsTooLong(),
|
|
49
|
+
{
|
|
50
|
+
name: "status is error: called on an empty transaction",
|
|
51
|
+
transaction: createTransaction({}),
|
|
52
|
+
expectedStatus: {
|
|
53
|
+
errors: {
|
|
54
|
+
recipient: new RecipientRequired(),
|
|
55
|
+
},
|
|
56
|
+
warnings: {},
|
|
57
|
+
estimatedFees: fees(1),
|
|
58
|
+
amount: zero,
|
|
59
|
+
totalSpent: fees(1),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
...transferTests(),
|
|
63
|
+
...stakingTests(),
|
|
64
|
+
...tokenTests(),
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
export const dataset = {
|
|
70
|
+
implementations: [getEnv("MOCK") ? "mock" : "js"], // FIXME we should actually put both mock and js like other dataset do
|
|
71
|
+
currencies: {
|
|
72
|
+
solana,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
function makeAccount(freshAddress) {
|
|
76
|
+
return {
|
|
77
|
+
id: mainAccId,
|
|
78
|
+
seedIdentifier: "",
|
|
79
|
+
derivationMode: "solanaMain",
|
|
80
|
+
index: 0,
|
|
81
|
+
freshAddress,
|
|
82
|
+
freshAddressPath: "",
|
|
83
|
+
blockHeight: 0,
|
|
84
|
+
operations: [],
|
|
85
|
+
pendingOperations: [],
|
|
86
|
+
currencyId: "solana",
|
|
87
|
+
lastSyncDate: "",
|
|
88
|
+
balance: "0",
|
|
89
|
+
subAccounts: [makeSubTokenAccount()],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function makeSubTokenAccount() {
|
|
93
|
+
return {
|
|
94
|
+
type: "TokenAccountRaw",
|
|
95
|
+
id: wSolSubAccId,
|
|
96
|
+
parentId: mainAccId,
|
|
97
|
+
tokenId: wSolToken.id,
|
|
98
|
+
balance: "0",
|
|
99
|
+
operations: [],
|
|
100
|
+
pendingOperations: [],
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function recipientRequired() {
|
|
104
|
+
const models = [
|
|
105
|
+
{
|
|
106
|
+
kind: "token.transfer",
|
|
107
|
+
uiState: {
|
|
108
|
+
subAccountId: wSolSubAccId,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
kind: "transfer",
|
|
113
|
+
uiState: {},
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
return models.map(model => {
|
|
117
|
+
return {
|
|
118
|
+
name: `${model.kind} :: status is error: recipient required`,
|
|
119
|
+
transaction: {
|
|
120
|
+
model,
|
|
121
|
+
amount: zero,
|
|
122
|
+
recipient: "",
|
|
123
|
+
family: "solana",
|
|
124
|
+
},
|
|
125
|
+
expectedStatus: {
|
|
126
|
+
errors: {
|
|
127
|
+
recipient: new RecipientRequired(),
|
|
128
|
+
},
|
|
129
|
+
warnings: {},
|
|
130
|
+
estimatedFees: fees(1),
|
|
131
|
+
amount: zero,
|
|
132
|
+
totalSpent: model.kind === "transfer" ? fees(1) : zero,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function recipientNotValid() {
|
|
138
|
+
return recipientRequired().map(spec => {
|
|
139
|
+
return {
|
|
140
|
+
...spec,
|
|
141
|
+
transaction: {
|
|
142
|
+
...spec.transaction,
|
|
143
|
+
recipient: "invalid address",
|
|
144
|
+
},
|
|
145
|
+
expectedStatus: {
|
|
146
|
+
...spec.expectedStatus,
|
|
147
|
+
errors: {
|
|
148
|
+
recipient: new InvalidAddress(),
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function recipientIsSameAsSender() {
|
|
155
|
+
return recipientRequired().map(spec => {
|
|
156
|
+
return {
|
|
157
|
+
...spec,
|
|
158
|
+
transaction: {
|
|
159
|
+
...spec.transaction,
|
|
160
|
+
recipient: testOnChainData.fundedSenderAddress,
|
|
161
|
+
},
|
|
162
|
+
expectedStatus: {
|
|
163
|
+
...spec.expectedStatus,
|
|
164
|
+
errors: {
|
|
165
|
+
recipient: new InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function memoIsTooLong() {
|
|
172
|
+
return compact(recipientRequired().map(spec => {
|
|
173
|
+
const tx = spec.transaction;
|
|
174
|
+
switch (tx.model.kind) {
|
|
175
|
+
case "transfer":
|
|
176
|
+
case "token.transfer":
|
|
177
|
+
tx.model.uiState.memo = "c".repeat(MAX_MEMO_LENGTH + 1);
|
|
178
|
+
return {
|
|
179
|
+
...spec,
|
|
180
|
+
transaction: {
|
|
181
|
+
...spec.transaction,
|
|
182
|
+
recipient: testOnChainData.fundedAddress,
|
|
183
|
+
},
|
|
184
|
+
expectedStatus: {
|
|
185
|
+
...spec.expectedStatus,
|
|
186
|
+
errors: {
|
|
187
|
+
memo: new SolanaMemoIsTooLong(),
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
case "token.createATA":
|
|
192
|
+
case "token.approve":
|
|
193
|
+
case "token.revoke":
|
|
194
|
+
case "stake.createAccount":
|
|
195
|
+
case "stake.delegate":
|
|
196
|
+
case "stake.undelegate":
|
|
197
|
+
case "stake.withdraw":
|
|
198
|
+
case "stake.split":
|
|
199
|
+
case "raw":
|
|
200
|
+
return undefined;
|
|
201
|
+
default:
|
|
202
|
+
return assertUnreachable(tx.model);
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
function transferTests() {
|
|
207
|
+
return [
|
|
208
|
+
{
|
|
209
|
+
name: "transfer :: status is success: not all amount",
|
|
210
|
+
transaction: {
|
|
211
|
+
model: {
|
|
212
|
+
kind: "transfer",
|
|
213
|
+
uiState: {},
|
|
214
|
+
},
|
|
215
|
+
amount: testOnChainData.fundedSenderBalance.dividedBy(2),
|
|
216
|
+
recipient: testOnChainData.fundedAddress,
|
|
217
|
+
family: "solana",
|
|
218
|
+
},
|
|
219
|
+
expectedStatus: {
|
|
220
|
+
errors: {},
|
|
221
|
+
warnings: {},
|
|
222
|
+
estimatedFees: fees(1),
|
|
223
|
+
amount: testOnChainData.fundedSenderBalance.dividedBy(2),
|
|
224
|
+
totalSpent: testOnChainData.fundedSenderBalance.dividedBy(2).plus(fees(1)),
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "transfer :: status is success: all amount",
|
|
229
|
+
transaction: {
|
|
230
|
+
model: {
|
|
231
|
+
kind: "transfer",
|
|
232
|
+
uiState: {},
|
|
233
|
+
},
|
|
234
|
+
useAllAmount: true,
|
|
235
|
+
amount: zero,
|
|
236
|
+
recipient: testOnChainData.fundedAddress,
|
|
237
|
+
family: "solana",
|
|
238
|
+
},
|
|
239
|
+
expectedStatus: {
|
|
240
|
+
errors: {},
|
|
241
|
+
warnings: {},
|
|
242
|
+
estimatedFees: fees(1),
|
|
243
|
+
amount: testOnChainData.fundedSenderBalance
|
|
244
|
+
.minus(fees(1))
|
|
245
|
+
.minus(testOnChainData.fees.systemAccountRentExempt),
|
|
246
|
+
totalSpent: testOnChainData.fundedSenderBalance.minus(testOnChainData.fees.systemAccountRentExempt),
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "transfer :: status is error: not enough balance, not all amount",
|
|
251
|
+
transaction: {
|
|
252
|
+
model: {
|
|
253
|
+
kind: "transfer",
|
|
254
|
+
uiState: {},
|
|
255
|
+
},
|
|
256
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
257
|
+
recipient: testOnChainData.fundedAddress,
|
|
258
|
+
family: "solana",
|
|
259
|
+
},
|
|
260
|
+
expectedStatus: {
|
|
261
|
+
errors: {
|
|
262
|
+
amount: new NotEnoughBalance(),
|
|
263
|
+
},
|
|
264
|
+
warnings: {},
|
|
265
|
+
estimatedFees: fees(1),
|
|
266
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
267
|
+
totalSpent: testOnChainData.fundedSenderBalance.plus(fees(1)),
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "transfer :: status is error: amount is 0",
|
|
272
|
+
transaction: {
|
|
273
|
+
model: {
|
|
274
|
+
kind: "transfer",
|
|
275
|
+
uiState: {},
|
|
276
|
+
},
|
|
277
|
+
amount: zero,
|
|
278
|
+
recipient: testOnChainData.fundedAddress,
|
|
279
|
+
family: "solana",
|
|
280
|
+
},
|
|
281
|
+
expectedStatus: {
|
|
282
|
+
errors: {
|
|
283
|
+
amount: new AmountRequired(),
|
|
284
|
+
},
|
|
285
|
+
warnings: {},
|
|
286
|
+
estimatedFees: fees(1),
|
|
287
|
+
amount: zero,
|
|
288
|
+
totalSpent: fees(1),
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
name: "transfer :: status is error: amount is negative",
|
|
293
|
+
transaction: {
|
|
294
|
+
model: {
|
|
295
|
+
kind: "transfer",
|
|
296
|
+
uiState: {},
|
|
297
|
+
},
|
|
298
|
+
amount: new BigNumber(-1),
|
|
299
|
+
recipient: testOnChainData.fundedAddress,
|
|
300
|
+
family: "solana",
|
|
301
|
+
},
|
|
302
|
+
expectedStatus: {
|
|
303
|
+
errors: {
|
|
304
|
+
amount: new AmountRequired(),
|
|
305
|
+
},
|
|
306
|
+
warnings: {},
|
|
307
|
+
estimatedFees: fees(1),
|
|
308
|
+
amount: new BigNumber(-1),
|
|
309
|
+
totalSpent: zero,
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "transfer :: status is warning: recipient wallet not funded",
|
|
314
|
+
transaction: {
|
|
315
|
+
model: {
|
|
316
|
+
kind: "transfer",
|
|
317
|
+
uiState: {},
|
|
318
|
+
},
|
|
319
|
+
amount: new BigNumber(1),
|
|
320
|
+
recipient: testOnChainData.unfundedAddress,
|
|
321
|
+
family: "solana",
|
|
322
|
+
},
|
|
323
|
+
expectedStatus: {
|
|
324
|
+
errors: {},
|
|
325
|
+
warnings: {
|
|
326
|
+
recipient: new SolanaAccountNotFunded(),
|
|
327
|
+
},
|
|
328
|
+
estimatedFees: fees(1),
|
|
329
|
+
amount: new BigNumber(1),
|
|
330
|
+
totalSpent: fees(1).plus(1),
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: "transfer :: status is warning: recipient address is off ed25519",
|
|
335
|
+
transaction: {
|
|
336
|
+
model: {
|
|
337
|
+
kind: "transfer",
|
|
338
|
+
uiState: {},
|
|
339
|
+
},
|
|
340
|
+
amount: new BigNumber(1),
|
|
341
|
+
recipient: testOnChainData.offEd25519Address,
|
|
342
|
+
family: "solana",
|
|
343
|
+
},
|
|
344
|
+
expectedStatus: {
|
|
345
|
+
errors: {},
|
|
346
|
+
warnings: {
|
|
347
|
+
recipient: new SolanaAccountNotFunded(),
|
|
348
|
+
recipientOffCurve: new SolanaAddressOffEd25519(),
|
|
349
|
+
},
|
|
350
|
+
estimatedFees: fees(1),
|
|
351
|
+
amount: new BigNumber(1),
|
|
352
|
+
totalSpent: fees(1).plus(1),
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
];
|
|
356
|
+
}
|
|
357
|
+
function tokenTests() {
|
|
358
|
+
return [
|
|
359
|
+
{
|
|
360
|
+
name: "token.transfer :: status is success: recipient is funded wallet, assoc token acc exists",
|
|
361
|
+
transaction: {
|
|
362
|
+
model: {
|
|
363
|
+
kind: "token.transfer",
|
|
364
|
+
uiState: {
|
|
365
|
+
subAccountId: wSolSubAccId,
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
369
|
+
recipient: testOnChainData.fundedAddress,
|
|
370
|
+
family: "solana",
|
|
371
|
+
},
|
|
372
|
+
expectedStatus: {
|
|
373
|
+
errors: {},
|
|
374
|
+
warnings: {},
|
|
375
|
+
estimatedFees: fees(1),
|
|
376
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
377
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
name: "token.transfer :: status is success: recipient is correct mint token acc",
|
|
382
|
+
transaction: {
|
|
383
|
+
model: {
|
|
384
|
+
kind: "token.transfer",
|
|
385
|
+
uiState: {
|
|
386
|
+
subAccountId: wSolSubAccId,
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
390
|
+
recipient: testOnChainData.wSolFundedAccountAssocTokenAccAddress,
|
|
391
|
+
family: "solana",
|
|
392
|
+
},
|
|
393
|
+
expectedStatus: {
|
|
394
|
+
errors: {},
|
|
395
|
+
warnings: {},
|
|
396
|
+
estimatedFees: fees(1),
|
|
397
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
398
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
name: "token.transfer :: status is error: recipient is another mint token acc",
|
|
403
|
+
transaction: {
|
|
404
|
+
model: {
|
|
405
|
+
kind: "token.transfer",
|
|
406
|
+
uiState: {
|
|
407
|
+
subAccountId: wSolSubAccId,
|
|
408
|
+
},
|
|
409
|
+
},
|
|
410
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
411
|
+
recipient: testOnChainData.notWSolTokenAccAddress,
|
|
412
|
+
family: "solana",
|
|
413
|
+
},
|
|
414
|
+
expectedStatus: {
|
|
415
|
+
errors: {
|
|
416
|
+
recipient: new SolanaTokenAccountHoldsAnotherToken(),
|
|
417
|
+
},
|
|
418
|
+
warnings: {},
|
|
419
|
+
estimatedFees: fees(1),
|
|
420
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
421
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: "token.transfer :: status is warning: recipient is off curve",
|
|
426
|
+
transaction: {
|
|
427
|
+
model: {
|
|
428
|
+
kind: "token.transfer",
|
|
429
|
+
uiState: {
|
|
430
|
+
subAccountId: wSolSubAccId,
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
434
|
+
recipient: testOnChainData.offEd25519Address,
|
|
435
|
+
family: "solana",
|
|
436
|
+
},
|
|
437
|
+
expectedStatus: {
|
|
438
|
+
errors: {
|
|
439
|
+
recipient: new SolanaAddressOffEd25519(),
|
|
440
|
+
},
|
|
441
|
+
warnings: {},
|
|
442
|
+
estimatedFees: fees(1),
|
|
443
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
444
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
445
|
+
},
|
|
446
|
+
},
|
|
447
|
+
{
|
|
448
|
+
name: "token.transfer :: status is success: recipient is wallet and no assoc token acc exists (will be created)",
|
|
449
|
+
transaction: {
|
|
450
|
+
model: {
|
|
451
|
+
kind: "token.transfer",
|
|
452
|
+
uiState: {
|
|
453
|
+
subAccountId: wSolSubAccId,
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
457
|
+
recipient: testOnChainData.unfundedAddress,
|
|
458
|
+
family: "solana",
|
|
459
|
+
},
|
|
460
|
+
expectedStatus: {
|
|
461
|
+
errors: {},
|
|
462
|
+
warnings: {
|
|
463
|
+
recipient: new SolanaRecipientAssociatedTokenAccountWillBeFunded(),
|
|
464
|
+
},
|
|
465
|
+
// this fee is dynamic, skip
|
|
466
|
+
//estimatedFees: new BigNumber(2044280),
|
|
467
|
+
amount: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
468
|
+
totalSpent: testOnChainData.wSolSenderAssocTokenAccBalance.dividedBy(2),
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
];
|
|
472
|
+
}
|
|
473
|
+
function stakingTests() {
|
|
474
|
+
return [
|
|
475
|
+
{
|
|
476
|
+
name: "stake.createAccount :: status is error: amount is negative",
|
|
477
|
+
transaction: {
|
|
478
|
+
family: "solana",
|
|
479
|
+
model: {
|
|
480
|
+
kind: "stake.createAccount",
|
|
481
|
+
uiState: {
|
|
482
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
483
|
+
},
|
|
484
|
+
},
|
|
485
|
+
recipient: "",
|
|
486
|
+
amount: new BigNumber(-1),
|
|
487
|
+
},
|
|
488
|
+
expectedStatus: {
|
|
489
|
+
amount: new BigNumber(-1),
|
|
490
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
491
|
+
totalSpent: zero,
|
|
492
|
+
errors: {
|
|
493
|
+
amount: new AmountRequired(),
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
name: "stake.createAccount :: status is error: amount is zero",
|
|
499
|
+
transaction: {
|
|
500
|
+
family: "solana",
|
|
501
|
+
model: {
|
|
502
|
+
kind: "stake.createAccount",
|
|
503
|
+
uiState: {
|
|
504
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
recipient: "",
|
|
508
|
+
amount: zero,
|
|
509
|
+
},
|
|
510
|
+
expectedStatus: {
|
|
511
|
+
amount: zero,
|
|
512
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
513
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
514
|
+
errors: {
|
|
515
|
+
amount: new AmountRequired(),
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
name: "stake.createAccount :: status is error: not enough balance, not all amount",
|
|
521
|
+
transaction: {
|
|
522
|
+
family: "solana",
|
|
523
|
+
model: {
|
|
524
|
+
kind: "stake.createAccount",
|
|
525
|
+
uiState: {
|
|
526
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
recipient: "",
|
|
530
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
531
|
+
},
|
|
532
|
+
expectedStatus: {
|
|
533
|
+
amount: testOnChainData.fundedSenderBalance,
|
|
534
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
535
|
+
totalSpent: fees(1)
|
|
536
|
+
.plus(testOnChainData.fees.stakeAccountRentExempt)
|
|
537
|
+
.plus(testOnChainData.fundedSenderBalance),
|
|
538
|
+
errors: {
|
|
539
|
+
amount: new NotEnoughBalance(),
|
|
540
|
+
},
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
name: "stake.createAccount :: status is error: validator required",
|
|
545
|
+
transaction: {
|
|
546
|
+
family: "solana",
|
|
547
|
+
model: {
|
|
548
|
+
kind: "stake.createAccount",
|
|
549
|
+
uiState: {
|
|
550
|
+
delegate: { voteAccAddress: "" },
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
recipient: "",
|
|
554
|
+
amount: new BigNumber(1),
|
|
555
|
+
},
|
|
556
|
+
expectedStatus: {
|
|
557
|
+
amount: new BigNumber(1),
|
|
558
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
559
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
560
|
+
errors: {
|
|
561
|
+
voteAccAddr: new SolanaValidatorRequired(),
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
name: "stake.createAccount :: status is error: validator has invalid address",
|
|
567
|
+
transaction: {
|
|
568
|
+
family: "solana",
|
|
569
|
+
model: {
|
|
570
|
+
kind: "stake.createAccount",
|
|
571
|
+
uiState: {
|
|
572
|
+
delegate: { voteAccAddress: "invalid address" },
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
recipient: "",
|
|
576
|
+
amount: new BigNumber(1),
|
|
577
|
+
},
|
|
578
|
+
expectedStatus: {
|
|
579
|
+
amount: new BigNumber(1),
|
|
580
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
581
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
582
|
+
errors: {
|
|
583
|
+
voteAccAddr: new InvalidAddress(),
|
|
584
|
+
},
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
name: "stake.createAccount :: status is error: validator invalid",
|
|
589
|
+
transaction: {
|
|
590
|
+
family: "solana",
|
|
591
|
+
model: {
|
|
592
|
+
kind: "stake.createAccount",
|
|
593
|
+
uiState: {
|
|
594
|
+
delegate: { voteAccAddress: testOnChainData.fundedSenderAddress },
|
|
595
|
+
},
|
|
596
|
+
},
|
|
597
|
+
recipient: "",
|
|
598
|
+
amount: new BigNumber(1),
|
|
599
|
+
},
|
|
600
|
+
expectedStatus: {
|
|
601
|
+
amount: new BigNumber(1),
|
|
602
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
603
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
604
|
+
errors: {
|
|
605
|
+
voteAccAddr: new SolanaInvalidValidator(),
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
name: "stake.createAccount :: status is success, not all amount",
|
|
611
|
+
transaction: {
|
|
612
|
+
family: "solana",
|
|
613
|
+
model: {
|
|
614
|
+
kind: "stake.createAccount",
|
|
615
|
+
uiState: {
|
|
616
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
recipient: "",
|
|
620
|
+
amount: new BigNumber(1),
|
|
621
|
+
},
|
|
622
|
+
expectedStatus: {
|
|
623
|
+
amount: new BigNumber(1),
|
|
624
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
625
|
+
totalSpent: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt).plus(1),
|
|
626
|
+
errors: {},
|
|
627
|
+
},
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
name: "stake.createAccount :: status is success, all amount",
|
|
631
|
+
transaction: {
|
|
632
|
+
family: "solana",
|
|
633
|
+
model: {
|
|
634
|
+
kind: "stake.createAccount",
|
|
635
|
+
uiState: {
|
|
636
|
+
delegate: { voteAccAddress: testOnChainData.validatorAddress },
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
recipient: "",
|
|
640
|
+
useAllAmount: true,
|
|
641
|
+
amount: zero,
|
|
642
|
+
},
|
|
643
|
+
expectedStatus: {
|
|
644
|
+
amount: testOnChainData.fundedSenderBalance
|
|
645
|
+
.minus(fees(1)) // transaction fee
|
|
646
|
+
.minus(fees(1).multipliedBy(2)) // undelegate + withdraw fees reserve
|
|
647
|
+
.minus(testOnChainData.fees.stakeAccountRentExempt)
|
|
648
|
+
.minus(testOnChainData.fees.systemAccountRentExempt),
|
|
649
|
+
estimatedFees: fees(1).plus(testOnChainData.fees.stakeAccountRentExempt),
|
|
650
|
+
totalSpent: testOnChainData.fundedSenderBalance
|
|
651
|
+
.minus(testOnChainData.fees.systemAccountRentExempt)
|
|
652
|
+
.minus(fees(1).multipliedBy(2)), // undelegate + withdraw fees reserve,
|
|
653
|
+
errors: {},
|
|
654
|
+
},
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
name: "stake.delegate :: status is error: stake account address and validator address required",
|
|
658
|
+
transaction: {
|
|
659
|
+
family: "solana",
|
|
660
|
+
model: {
|
|
661
|
+
kind: "stake.delegate",
|
|
662
|
+
uiState: {
|
|
663
|
+
stakeAccAddr: "",
|
|
664
|
+
voteAccAddr: "",
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
recipient: "",
|
|
668
|
+
amount: zero,
|
|
669
|
+
},
|
|
670
|
+
expectedStatus: {
|
|
671
|
+
amount: zero,
|
|
672
|
+
estimatedFees: fees(1),
|
|
673
|
+
totalSpent: fees(1),
|
|
674
|
+
errors: {
|
|
675
|
+
stakeAccAddr: new SolanaStakeAccountRequired(),
|
|
676
|
+
voteAccAddr: new SolanaValidatorRequired(),
|
|
677
|
+
},
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
{
|
|
681
|
+
name: "stake.delegate :: status is error: stake account address and validator address are invalid",
|
|
682
|
+
transaction: {
|
|
683
|
+
family: "solana",
|
|
684
|
+
model: {
|
|
685
|
+
kind: "stake.delegate",
|
|
686
|
+
uiState: {
|
|
687
|
+
stakeAccAddr: "invalid address",
|
|
688
|
+
voteAccAddr: "invalid address",
|
|
689
|
+
},
|
|
690
|
+
},
|
|
691
|
+
recipient: "",
|
|
692
|
+
amount: zero,
|
|
693
|
+
},
|
|
694
|
+
expectedStatus: {
|
|
695
|
+
amount: zero,
|
|
696
|
+
estimatedFees: fees(1),
|
|
697
|
+
totalSpent: fees(1),
|
|
698
|
+
errors: {
|
|
699
|
+
stakeAccAddr: new InvalidAddress(),
|
|
700
|
+
voteAccAddr: new InvalidAddress(),
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
name: "stake.delegate :: status is error: stake account not found",
|
|
706
|
+
transaction: {
|
|
707
|
+
family: "solana",
|
|
708
|
+
model: {
|
|
709
|
+
kind: "stake.delegate",
|
|
710
|
+
uiState: {
|
|
711
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
712
|
+
voteAccAddr: testOnChainData.validatorAddress,
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
recipient: "",
|
|
716
|
+
amount: zero,
|
|
717
|
+
},
|
|
718
|
+
expectedStatus: {
|
|
719
|
+
amount: zero,
|
|
720
|
+
estimatedFees: fees(1),
|
|
721
|
+
totalSpent: fees(1),
|
|
722
|
+
errors: {
|
|
723
|
+
stakeAccAddr: new SolanaStakeAccountNotFound(),
|
|
724
|
+
},
|
|
725
|
+
},
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
name: "stake.undelegate :: status is error: stake account required",
|
|
729
|
+
transaction: {
|
|
730
|
+
family: "solana",
|
|
731
|
+
model: {
|
|
732
|
+
kind: "stake.undelegate",
|
|
733
|
+
uiState: {
|
|
734
|
+
stakeAccAddr: "",
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
recipient: "",
|
|
738
|
+
amount: zero,
|
|
739
|
+
},
|
|
740
|
+
expectedStatus: {
|
|
741
|
+
amount: zero,
|
|
742
|
+
estimatedFees: fees(1),
|
|
743
|
+
totalSpent: fees(1),
|
|
744
|
+
errors: {
|
|
745
|
+
stakeAccAddr: new SolanaStakeAccountRequired(),
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
name: "stake.undelegate :: status is error: stake account invalid",
|
|
751
|
+
transaction: {
|
|
752
|
+
family: "solana",
|
|
753
|
+
model: {
|
|
754
|
+
kind: "stake.undelegate",
|
|
755
|
+
uiState: {
|
|
756
|
+
stakeAccAddr: "invalid address",
|
|
757
|
+
},
|
|
758
|
+
},
|
|
759
|
+
recipient: "",
|
|
760
|
+
amount: zero,
|
|
761
|
+
},
|
|
762
|
+
expectedStatus: {
|
|
763
|
+
amount: zero,
|
|
764
|
+
estimatedFees: fees(1),
|
|
765
|
+
totalSpent: fees(1),
|
|
766
|
+
errors: {
|
|
767
|
+
stakeAccAddr: new InvalidAddress(),
|
|
768
|
+
},
|
|
769
|
+
},
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
name: "stake.undelegate :: status is error: stake account not found",
|
|
773
|
+
transaction: {
|
|
774
|
+
family: "solana",
|
|
775
|
+
model: {
|
|
776
|
+
kind: "stake.undelegate",
|
|
777
|
+
uiState: {
|
|
778
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
779
|
+
},
|
|
780
|
+
},
|
|
781
|
+
recipient: "",
|
|
782
|
+
amount: zero,
|
|
783
|
+
},
|
|
784
|
+
expectedStatus: {
|
|
785
|
+
amount: zero,
|
|
786
|
+
estimatedFees: fees(1),
|
|
787
|
+
totalSpent: fees(1),
|
|
788
|
+
errors: {
|
|
789
|
+
stakeAccAddr: new SolanaStakeAccountNotFound(),
|
|
790
|
+
},
|
|
791
|
+
},
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
name: "stake.withdraw :: status is error: stake account required",
|
|
795
|
+
transaction: {
|
|
796
|
+
family: "solana",
|
|
797
|
+
model: {
|
|
798
|
+
kind: "stake.withdraw",
|
|
799
|
+
uiState: {
|
|
800
|
+
stakeAccAddr: "",
|
|
801
|
+
},
|
|
802
|
+
},
|
|
803
|
+
recipient: "",
|
|
804
|
+
amount: zero,
|
|
805
|
+
},
|
|
806
|
+
expectedStatus: {
|
|
807
|
+
amount: zero,
|
|
808
|
+
estimatedFees: fees(1),
|
|
809
|
+
totalSpent: fees(1),
|
|
810
|
+
errors: {
|
|
811
|
+
stakeAccAddr: new SolanaStakeAccountRequired(),
|
|
812
|
+
},
|
|
813
|
+
},
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
name: "stake.withdraw :: status is error: stake account address invalid",
|
|
817
|
+
transaction: {
|
|
818
|
+
family: "solana",
|
|
819
|
+
model: {
|
|
820
|
+
kind: "stake.withdraw",
|
|
821
|
+
uiState: {
|
|
822
|
+
stakeAccAddr: "invalid address",
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
recipient: "",
|
|
826
|
+
amount: zero,
|
|
827
|
+
},
|
|
828
|
+
expectedStatus: {
|
|
829
|
+
amount: zero,
|
|
830
|
+
estimatedFees: fees(1),
|
|
831
|
+
totalSpent: fees(1),
|
|
832
|
+
errors: {
|
|
833
|
+
stakeAccAddr: new InvalidAddress(),
|
|
834
|
+
},
|
|
835
|
+
},
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
name: "stake.withdraw :: status is error: stake account not found",
|
|
839
|
+
transaction: {
|
|
840
|
+
family: "solana",
|
|
841
|
+
model: {
|
|
842
|
+
kind: "stake.withdraw",
|
|
843
|
+
uiState: {
|
|
844
|
+
stakeAccAddr: testOnChainData.unfundedAddress,
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
recipient: "",
|
|
848
|
+
amount: zero,
|
|
849
|
+
},
|
|
850
|
+
expectedStatus: {
|
|
851
|
+
amount: zero,
|
|
852
|
+
estimatedFees: fees(1),
|
|
853
|
+
totalSpent: fees(1),
|
|
854
|
+
errors: {
|
|
855
|
+
stakeAccAddr: new SolanaStakeAccountNotFound(),
|
|
856
|
+
},
|
|
857
|
+
},
|
|
858
|
+
},
|
|
859
|
+
];
|
|
860
|
+
}
|
|
861
|
+
describe("Solana bridge", () => {
|
|
862
|
+
test.todo("This is an empty test to make jest command pass. Remove it once there is a real test.");
|
|
863
|
+
});
|
|
864
|
+
//# sourceMappingURL=bridge.integration.test.js.map
|