@cityofzion/bs-solana 3.1.3 → 3.1.5
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/BSSolana.d.ts +14 -14
- package/dist/BSSolana.js +11 -13
- package/dist/services/blockchain-data/RpcBDSSolana.d.ts +4 -4
- package/dist/services/blockchain-data/RpcBDSSolana.js +6 -12
- package/dist/services/exchange/MoralisEDSSolana.d.ts +2 -2
- package/dist/services/explorer/SolScanESSolana.d.ts +2 -2
- package/dist/services/ledger/Web3LedgerServiceSolana.d.ts +7 -7
- package/dist/services/nft-data/RpcNDSSolana.d.ts +2 -2
- package/dist/services/token/TokenServiceSolana.d.ts +2 -1
- package/dist/services/wallet-connect/WalletConnectServiceSolana.d.ts +10 -10
- package/dist/services/wallet-connect/WalletConnectServiceSolana.js +5 -5
- package/dist/types.d.ts +4 -3
- package/package.json +3 -3
package/dist/BSSolana.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type TBSAccount, type TGetLedgerTransport, type IBlockchainDataService, type IExchangeDataService, type IExplorerService, type INftDataService, type ITokenService, type TBSNetwork, type TBSToken, type TPingNetworkResponse, type TTransferParams, type IWalletConnectService, type TTransactionDefault } from '@cityofzion/blockchain-service';
|
|
2
2
|
import { Web3LedgerServiceSolana } from './services/ledger/Web3LedgerServiceSolana';
|
|
3
|
-
import type { IBSSolana, TBSSolanaNetworkId } from './types';
|
|
3
|
+
import type { IBSSolana, TBSSolanaName, TBSSolanaNetworkId } from './types';
|
|
4
4
|
import * as solanaKit from '@solana/kit';
|
|
5
|
-
export declare class BSSolana
|
|
5
|
+
export declare class BSSolana implements IBSSolana {
|
|
6
6
|
#private;
|
|
7
|
-
readonly name
|
|
7
|
+
readonly name = "solana";
|
|
8
8
|
readonly bipDerivationPath: string;
|
|
9
9
|
readonly isMultiTransferSupported = true;
|
|
10
10
|
readonly isCustomNetworkSupported = false;
|
|
@@ -15,25 +15,25 @@ export declare class BSSolana<N extends string = string> implements IBSSolana<N>
|
|
|
15
15
|
networkUrls: string[];
|
|
16
16
|
readonly availableNetworks: TBSNetwork<TBSSolanaNetworkId>[];
|
|
17
17
|
readonly defaultNetwork: TBSNetwork<TBSSolanaNetworkId>;
|
|
18
|
-
ledgerService: Web3LedgerServiceSolana
|
|
18
|
+
ledgerService: Web3LedgerServiceSolana;
|
|
19
19
|
exchangeDataService: IExchangeDataService;
|
|
20
|
-
blockchainDataService: IBlockchainDataService
|
|
20
|
+
blockchainDataService: IBlockchainDataService;
|
|
21
21
|
nftDataService: INftDataService;
|
|
22
22
|
explorerService: IExplorerService;
|
|
23
23
|
tokenService: ITokenService;
|
|
24
|
-
walletConnectService: IWalletConnectService<
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
|
|
24
|
+
walletConnectService: IWalletConnectService<TBSSolanaName>;
|
|
25
|
+
_solanaKitRpc: solanaKit.Rpc<solanaKit.SolanaRpcApi>;
|
|
26
|
+
constructor(network?: TBSNetwork<TBSSolanaNetworkId>, getLedgerTransport?: TGetLedgerTransport<TBSSolanaName>);
|
|
27
|
+
_signTransaction(transaction: solanaKit.Transaction, senderAccount: TBSAccount<TBSSolanaName>): Promise<solanaKit.Base64EncodedWireTransaction>;
|
|
28
28
|
setNetwork(network: TBSNetwork<TBSSolanaNetworkId>): void;
|
|
29
29
|
pingNetwork(url: string): Promise<TPingNetworkResponse>;
|
|
30
30
|
validateAddress(address: string): boolean;
|
|
31
31
|
validateKey(key: string): boolean;
|
|
32
|
-
generateAccountFromMnemonic(mnemonic: string, index: number): Promise<TBSAccount<
|
|
33
|
-
generateAccountFromKey(key: string): Promise<TBSAccount<
|
|
34
|
-
generateAccountFromPublicKey(publicKey: string): Promise<TBSAccount<
|
|
35
|
-
transfer(params: TTransferParams<
|
|
36
|
-
calculateTransferFee(params: TTransferParams<
|
|
32
|
+
generateAccountFromMnemonic(mnemonic: string, index: number): Promise<TBSAccount<TBSSolanaName>>;
|
|
33
|
+
generateAccountFromKey(key: string): Promise<TBSAccount<TBSSolanaName>>;
|
|
34
|
+
generateAccountFromPublicKey(publicKey: string): Promise<TBSAccount<TBSSolanaName>>;
|
|
35
|
+
transfer(params: TTransferParams<TBSSolanaName>): Promise<TTransactionDefault[]>;
|
|
36
|
+
calculateTransferFee(params: TTransferParams<TBSSolanaName>): Promise<string>;
|
|
37
37
|
resolveNameServiceDomain(domainName: string): Promise<string>;
|
|
38
38
|
validateNameServiceDomainFormat(domainName: string): boolean;
|
|
39
39
|
}
|
package/dist/BSSolana.js
CHANGED
|
@@ -58,11 +58,11 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
58
58
|
const WalletConnectServiceSolana_1 = require("./services/wallet-connect/WalletConnectServiceSolana");
|
|
59
59
|
const KEY_BYTES_LENGTH = 64;
|
|
60
60
|
class BSSolana {
|
|
61
|
-
constructor(
|
|
61
|
+
constructor(network, getLedgerTransport) {
|
|
62
62
|
_BSSolana_instances.add(this);
|
|
63
|
+
this.name = 'solana';
|
|
63
64
|
this.isMultiTransferSupported = true;
|
|
64
65
|
this.isCustomNetworkSupported = false;
|
|
65
|
-
this.name = name;
|
|
66
66
|
this.bipDerivationPath = BSSolanaConstants_1.BSSolanaConstants.DEFAULT_BIP_DERIVATION_PATH;
|
|
67
67
|
this.ledgerService = new Web3LedgerServiceSolana_1.Web3LedgerServiceSolana(this, getLedgerTransport);
|
|
68
68
|
this.tokens = [BSSolanaConstants_1.BSSolanaConstants.NATIVE_TOKEN];
|
|
@@ -72,7 +72,7 @@ class BSSolana {
|
|
|
72
72
|
this.defaultNetwork = BSSolanaConstants_1.BSSolanaConstants.MAINNET_NETWORK;
|
|
73
73
|
this.setNetwork(network ?? this.defaultNetwork);
|
|
74
74
|
}
|
|
75
|
-
async
|
|
75
|
+
async _signTransaction(transaction, senderAccount) {
|
|
76
76
|
if (senderAccount.isHardware) {
|
|
77
77
|
if (!this.ledgerService.getLedgerTransport)
|
|
78
78
|
throw new Error('You must provide getLedgerTransport function to use Ledger');
|
|
@@ -94,13 +94,13 @@ class BSSolana {
|
|
|
94
94
|
}
|
|
95
95
|
this.network = network;
|
|
96
96
|
this.networkUrls = networkUrls;
|
|
97
|
-
this.tokenService = new TokenServiceSolana_1.TokenServiceSolana();
|
|
97
|
+
this.tokenService = new TokenServiceSolana_1.TokenServiceSolana(this);
|
|
98
98
|
this.blockchainDataService = new RpcBDSSolana_1.RpcBDSSolana(this);
|
|
99
99
|
this.nftDataService = new RpcNDSSolana_1.RpcNDSSolana(this);
|
|
100
100
|
this.explorerService = new SolScanESSolana_1.SolScanESSolana(this);
|
|
101
101
|
this.exchangeDataService = new MoralisEDSSolana_1.MoralisEDSSolana(this);
|
|
102
102
|
this.walletConnectService = new WalletConnectServiceSolana_1.WalletConnectServiceSolana(this);
|
|
103
|
-
this.
|
|
103
|
+
this._solanaKitRpc = solanaKit.createSolanaRpc(this.network.url);
|
|
104
104
|
}
|
|
105
105
|
// This method is done manually because we need to ensure that the request is aborted after timeout
|
|
106
106
|
async pingNetwork(url) {
|
|
@@ -109,7 +109,7 @@ class BSSolana {
|
|
|
109
109
|
abortController.abort();
|
|
110
110
|
}, 5000);
|
|
111
111
|
const timeStart = Date.now();
|
|
112
|
-
const blockHeight = await this.
|
|
112
|
+
const blockHeight = await this._solanaKitRpc.getBlockHeight().send({ abortSignal: abortController.signal });
|
|
113
113
|
const latency = Date.now() - timeStart;
|
|
114
114
|
clearTimeout(timeout);
|
|
115
115
|
return {
|
|
@@ -175,8 +175,8 @@ class BSSolana {
|
|
|
175
175
|
const compiledTransaction = solanaKit.compileTransaction(transactionMessage);
|
|
176
176
|
const fee = await __classPrivateFieldGet(this, _BSSolana_instances, "m", _BSSolana_getFeeByMessageBytes).call(this, compiledTransaction.messageBytes);
|
|
177
177
|
const { intents, senderAccount } = params;
|
|
178
|
-
const encodedSignedTransaction = await this.
|
|
179
|
-
const txId = await this.
|
|
178
|
+
const encodedSignedTransaction = await this._signTransaction(compiledTransaction, senderAccount);
|
|
179
|
+
const txId = await this._solanaKitRpc.sendTransaction(encodedSignedTransaction, { encoding: 'base64' }).send();
|
|
180
180
|
const { address } = senderAccount;
|
|
181
181
|
const addressUrl = this.explorerService.buildAddressUrl(address);
|
|
182
182
|
const nativeTokenHash = BSSolanaConstants_1.BSSolanaConstants.NATIVE_TOKEN.hash;
|
|
@@ -186,7 +186,6 @@ class BSSolana {
|
|
|
186
186
|
txIdUrl: this.explorerService.buildTransactionUrl(txId),
|
|
187
187
|
date: new Date().toJSON(),
|
|
188
188
|
networkFeeAmount: fee,
|
|
189
|
-
type: 'default',
|
|
190
189
|
view: 'default',
|
|
191
190
|
events: intents.map(({ amount, receiverAddress, token }) => {
|
|
192
191
|
const tokenHash = token.hash;
|
|
@@ -199,7 +198,6 @@ class BSSolana {
|
|
|
199
198
|
fromUrl: addressUrl,
|
|
200
199
|
to: receiverAddress,
|
|
201
200
|
toUrl: this.explorerService.buildAddressUrl(receiverAddress),
|
|
202
|
-
tokenType: isNativeToken ? 'native' : 'spl',
|
|
203
201
|
tokenUrl: this.explorerService.buildContractUrl(tokenHash),
|
|
204
202
|
token,
|
|
205
203
|
};
|
|
@@ -257,7 +255,7 @@ _BSSolana_instances = new WeakSet(), _BSSolana_buildTransferParams = async funct
|
|
|
257
255
|
owner: receiverAddress,
|
|
258
256
|
tokenProgram: solanaToken.TOKEN_PROGRAM_ADDRESS,
|
|
259
257
|
});
|
|
260
|
-
const receiverAccountInfo = await this.
|
|
258
|
+
const receiverAccountInfo = await this._solanaKitRpc.getAccountInfo(receiverATA, { encoding: 'base64' }).send();
|
|
261
259
|
if (!receiverAccountInfo.value) {
|
|
262
260
|
// Create associated token account for receiver
|
|
263
261
|
const createAtaInstruction = solanaToken.getCreateAssociatedTokenInstruction({
|
|
@@ -278,14 +276,14 @@ _BSSolana_instances = new WeakSet(), _BSSolana_buildTransferParams = async funct
|
|
|
278
276
|
});
|
|
279
277
|
instructions.push(transferInstruction);
|
|
280
278
|
}
|
|
281
|
-
const { value: latestBlockhash } = await this.
|
|
279
|
+
const { value: latestBlockhash } = await this._solanaKitRpc.getLatestBlockhash().send();
|
|
282
280
|
const transactionMessage = solanaKit.pipe(solanaKit.createTransactionMessage({ version: 0 }), tx => solanaKit.setTransactionMessageFeePayerSigner(signer, tx), tx => solanaKit.setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx), tx => solanaKit.appendTransactionMessageInstructions(instructions, tx));
|
|
283
281
|
return {
|
|
284
282
|
transactionMessage,
|
|
285
283
|
};
|
|
286
284
|
}, _BSSolana_getFeeByMessageBytes = async function _BSSolana_getFeeByMessageBytes(messageBytes) {
|
|
287
285
|
const messageBase64 = solanaKit.getBase64Decoder().decode(messageBytes);
|
|
288
|
-
const feeResponse = await this.
|
|
286
|
+
const feeResponse = await this._solanaKitRpc
|
|
289
287
|
.getFeeForMessage(messageBase64, { commitment: 'confirmed' })
|
|
290
288
|
.send();
|
|
291
289
|
if (!feeResponse.value) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { TBalanceResponse, IBlockchainDataService, TBSToken, type TContractResponse, type TGetTransactionsByAddressParams, type TGetTransactionsByAddressResponse, type TTransactionDefault } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { IBSSolana } from '../../types';
|
|
3
|
-
export declare class RpcBDSSolana
|
|
3
|
+
export declare class RpcBDSSolana implements IBlockchainDataService {
|
|
4
4
|
#private;
|
|
5
5
|
readonly maxTimeToConfirmTransactionInMs: number;
|
|
6
|
-
constructor(service: IBSSolana
|
|
7
|
-
getTransaction(txid: string): Promise<TTransactionDefault
|
|
8
|
-
getTransactionsByAddress(params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<
|
|
6
|
+
constructor(service: IBSSolana);
|
|
7
|
+
getTransaction(txid: string): Promise<TTransactionDefault>;
|
|
8
|
+
getTransactionsByAddress(params: TGetTransactionsByAddressParams): Promise<TGetTransactionsByAddressResponse<TTransactionDefault>>;
|
|
9
9
|
getContract(_contractHash: string): Promise<TContractResponse>;
|
|
10
10
|
getTokenInfo(tokenHash: string): Promise<TBSToken>;
|
|
11
11
|
getBalance(address: string): Promise<TBalanceResponse[]>;
|
|
@@ -66,7 +66,7 @@ class RpcBDSSolana {
|
|
|
66
66
|
}
|
|
67
67
|
async getTransaction(txid) {
|
|
68
68
|
const signature = solanaKit.signature(txid);
|
|
69
|
-
const transaction = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").
|
|
69
|
+
const transaction = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f")._solanaKitRpc
|
|
70
70
|
.getTransaction(signature, { encoding: 'jsonParsed', maxSupportedTransactionVersion: 0 })
|
|
71
71
|
.send();
|
|
72
72
|
const parsedTransaction = await __classPrivateFieldGet(this, _RpcBDSSolana_instances, "m", _RpcBDSSolana_parseTransaction).call(this, transaction, transaction?.blockTime, transaction?.slot);
|
|
@@ -76,7 +76,7 @@ class RpcBDSSolana {
|
|
|
76
76
|
}
|
|
77
77
|
async getTransactionsByAddress(params) {
|
|
78
78
|
const solanaKitAddress = solanaKit.address(params.address);
|
|
79
|
-
const signaturesResponse = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").
|
|
79
|
+
const signaturesResponse = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f")._solanaKitRpc
|
|
80
80
|
.getSignaturesForAddress(solanaKitAddress, {
|
|
81
81
|
limit: 15,
|
|
82
82
|
before: params.nextPageParams,
|
|
@@ -140,8 +140,8 @@ class RpcBDSSolana {
|
|
|
140
140
|
}
|
|
141
141
|
async getBalance(address) {
|
|
142
142
|
const solanaKitAddress = solanaKit.address(address);
|
|
143
|
-
const nativeBalance = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").
|
|
144
|
-
const splBalance = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").
|
|
143
|
+
const nativeBalance = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f")._solanaKitRpc.getBalance(solanaKitAddress).send();
|
|
144
|
+
const splBalance = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f")._solanaKitRpc
|
|
145
145
|
.getTokenAccountsByOwner(solanaKitAddress, { programId: solanaToken.TOKEN_PROGRAM_ADDRESS }, { encoding: 'jsonParsed' })
|
|
146
146
|
.send();
|
|
147
147
|
const nativeBalanceBn = blockchain_service_1.BSBigNumberHelper.fromDecimals(nativeBalance.value, BSSolanaConstants_1.BSSolanaConstants.NATIVE_TOKEN.decimals);
|
|
@@ -162,7 +162,7 @@ class RpcBDSSolana {
|
|
|
162
162
|
return balances;
|
|
163
163
|
}
|
|
164
164
|
async getBlockHeight() {
|
|
165
|
-
const blockHeight = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").
|
|
165
|
+
const blockHeight = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f")._solanaKitRpc.getBlockHeight().send();
|
|
166
166
|
return blockchain_service_1.BSBigNumberHelper.fromNumber(blockHeight).toNumber();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
@@ -175,7 +175,7 @@ _RpcBDSSolana_service = new WeakMap(), _RpcBDSSolana_tokenCache = new WeakMap(),
|
|
|
175
175
|
let accountInfoValue = null;
|
|
176
176
|
try {
|
|
177
177
|
const sourcePubkey = solanaKit.address(address);
|
|
178
|
-
const accountInfo = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").
|
|
178
|
+
const accountInfo = await __classPrivateFieldGet(this, _RpcBDSSolana_service, "f")._solanaKitRpc
|
|
179
179
|
.getAccountInfo(sourcePubkey, { encoding: 'jsonParsed' })
|
|
180
180
|
.send();
|
|
181
181
|
accountInfoValue = accountInfo.value;
|
|
@@ -232,7 +232,6 @@ _RpcBDSSolana_service = new WeakMap(), _RpcBDSSolana_tokenCache = new WeakMap(),
|
|
|
232
232
|
fromUrl,
|
|
233
233
|
to,
|
|
234
234
|
toUrl,
|
|
235
|
-
tokenType: 'spl',
|
|
236
235
|
nft,
|
|
237
236
|
};
|
|
238
237
|
}
|
|
@@ -246,7 +245,6 @@ _RpcBDSSolana_service = new WeakMap(), _RpcBDSSolana_tokenCache = new WeakMap(),
|
|
|
246
245
|
fromUrl,
|
|
247
246
|
to,
|
|
248
247
|
toUrl,
|
|
249
|
-
tokenType: 'spl',
|
|
250
248
|
tokenUrl: __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").explorerService.buildContractUrl(token.hash),
|
|
251
249
|
token,
|
|
252
250
|
};
|
|
@@ -291,7 +289,6 @@ _RpcBDSSolana_service = new WeakMap(), _RpcBDSSolana_tokenCache = new WeakMap(),
|
|
|
291
289
|
fromUrl,
|
|
292
290
|
to,
|
|
293
291
|
toUrl,
|
|
294
|
-
tokenType: 'spl',
|
|
295
292
|
nft,
|
|
296
293
|
};
|
|
297
294
|
}
|
|
@@ -305,7 +302,6 @@ _RpcBDSSolana_service = new WeakMap(), _RpcBDSSolana_tokenCache = new WeakMap(),
|
|
|
305
302
|
fromUrl,
|
|
306
303
|
to,
|
|
307
304
|
toUrl,
|
|
308
|
-
tokenType: 'spl',
|
|
309
305
|
tokenUrl: __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").explorerService.buildContractUrl(token.hash),
|
|
310
306
|
token,
|
|
311
307
|
};
|
|
@@ -326,7 +322,6 @@ _RpcBDSSolana_service = new WeakMap(), _RpcBDSSolana_tokenCache = new WeakMap(),
|
|
|
326
322
|
fromUrl: __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").explorerService.buildAddressUrl(from),
|
|
327
323
|
to,
|
|
328
324
|
toUrl: __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").explorerService.buildAddressUrl(to),
|
|
329
|
-
tokenType: 'native',
|
|
330
325
|
tokenUrl: __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").explorerService.buildContractUrl(BSSolanaConstants_1.BSSolanaConstants.NATIVE_TOKEN.hash),
|
|
331
326
|
token: BSSolanaConstants_1.BSSolanaConstants.NATIVE_TOKEN,
|
|
332
327
|
};
|
|
@@ -366,7 +361,6 @@ _RpcBDSSolana_service = new WeakMap(), _RpcBDSSolana_tokenCache = new WeakMap(),
|
|
|
366
361
|
block: blockchain_service_1.BSBigNumberHelper.fromNumber(block).toNumber(),
|
|
367
362
|
date: new Date(blockchain_service_1.BSBigNumberHelper.fromNumber(blockTime).multipliedBy(1000).toNumber()).toJSON(),
|
|
368
363
|
networkFeeAmount: blockchain_service_1.BSBigNumberHelper.format(blockchain_service_1.BSBigNumberHelper.fromDecimals(transaction.meta.fee, __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").feeToken.decimals), { decimals: __classPrivateFieldGet(this, _RpcBDSSolana_service, "f").feeToken.decimals }),
|
|
369
|
-
type: 'default',
|
|
370
364
|
view: 'default',
|
|
371
365
|
events,
|
|
372
366
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CryptoCompareEDS, type TGetTokenPriceHistoryParams, type TGetTokenPricesParams, type TTokenPricesHistoryResponse, type TTokenPricesResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { IBSSolana } from '../../types';
|
|
3
|
-
export declare class MoralisEDSSolana
|
|
3
|
+
export declare class MoralisEDSSolana extends CryptoCompareEDS {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(service: IBSSolana
|
|
5
|
+
constructor(service: IBSSolana);
|
|
6
6
|
getTokenPrices({ tokens }: TGetTokenPricesParams): Promise<TTokenPricesResponse[]>;
|
|
7
7
|
getTokenPriceHistory(params: TGetTokenPriceHistoryParams): Promise<TTokenPricesHistoryResponse[]>;
|
|
8
8
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { TBuildNftUrlParams, IExplorerService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { IBSSolana } from '../../types';
|
|
3
|
-
export declare class SolScanESSolana
|
|
3
|
+
export declare class SolScanESSolana implements IExplorerService {
|
|
4
4
|
#private;
|
|
5
|
-
constructor(service: IBSSolana
|
|
5
|
+
constructor(service: IBSSolana);
|
|
6
6
|
buildTransactionUrl(transactionId: string): string | undefined;
|
|
7
7
|
buildContractUrl(contractHash: string): string | undefined;
|
|
8
8
|
buildNftUrl({ tokenHash }: TBuildNftUrlParams): string | undefined;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type TBSAccount, type TLedgerServiceEmitter, type TGetLedgerTransport, type TUntilIndexRecord, type ILedgerService } from '@cityofzion/blockchain-service';
|
|
2
2
|
import Transport from '@ledgerhq/hw-transport';
|
|
3
|
-
import type { IBSSolana } from '../../types';
|
|
3
|
+
import type { IBSSolana, TBSSolanaName } from '../../types';
|
|
4
4
|
import * as solanaKit from '@solana/kit';
|
|
5
|
-
export declare class Web3LedgerServiceSolana
|
|
5
|
+
export declare class Web3LedgerServiceSolana implements ILedgerService<TBSSolanaName> {
|
|
6
6
|
#private;
|
|
7
|
-
readonly getLedgerTransport?: TGetLedgerTransport<
|
|
7
|
+
readonly getLedgerTransport?: TGetLedgerTransport<TBSSolanaName>;
|
|
8
8
|
emitter: TLedgerServiceEmitter;
|
|
9
|
-
constructor(blockchainService: IBSSolana
|
|
10
|
-
getAccounts(transport: Transport, untilIndexByBlockchainService?: TUntilIndexRecord<
|
|
11
|
-
getAccount(transport: Transport, index: number): Promise<TBSAccount<
|
|
12
|
-
signTransaction(transport: Transport, transaction: solanaKit.Transaction, account: TBSAccount<
|
|
9
|
+
constructor(blockchainService: IBSSolana, getLedgerTransport?: TGetLedgerTransport<TBSSolanaName>);
|
|
10
|
+
getAccounts(transport: Transport, untilIndexByBlockchainService?: TUntilIndexRecord<TBSSolanaName>): Promise<TBSAccount<TBSSolanaName>[]>;
|
|
11
|
+
getAccount(transport: Transport, index: number): Promise<TBSAccount<TBSSolanaName>>;
|
|
12
|
+
signTransaction(transport: Transport, transaction: solanaKit.Transaction, account: TBSAccount<TBSSolanaName>): Promise<solanaKit.Base64EncodedWireTransaction>;
|
|
13
13
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TGetNftParams, TGetNftsByAddressParams, THasTokenParams, INftDataService, TNftResponse, TNftsResponse } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { IBSSolana } from '../../types';
|
|
3
|
-
export declare class RpcNDSSolana
|
|
3
|
+
export declare class RpcNDSSolana implements INftDataService {
|
|
4
4
|
#private;
|
|
5
5
|
static readonly SUPPORTED_MIME_TYPES: string[];
|
|
6
|
-
constructor(service: IBSSolana
|
|
6
|
+
constructor(service: IBSSolana);
|
|
7
7
|
getNft(params: TGetNftParams): Promise<TNftResponse>;
|
|
8
8
|
getNftsByAddress({ address }: TGetNftsByAddressParams): Promise<TNftsResponse>;
|
|
9
9
|
hasToken({ address, collectionHash }: THasTokenParams): Promise<boolean>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TokenService } from '@cityofzion/blockchain-service';
|
|
2
|
-
|
|
2
|
+
import type { TBSSolanaName, TBSSolanaNetworkId } from '../../types';
|
|
3
|
+
export declare class TokenServiceSolana extends TokenService<TBSSolanaName, TBSSolanaNetworkId> {
|
|
3
4
|
normalizeHash(hash: string): string;
|
|
4
5
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IWalletConnectService, type TWalletConnectServiceRequestMethodParams } from '@cityofzion/blockchain-service';
|
|
2
|
-
import type { IBSSolana, TBSSolanaNetworkId } from '../../types';
|
|
2
|
+
import type { IBSSolana, TBSSolanaName, TBSSolanaNetworkId } from '../../types';
|
|
3
3
|
import * as solanaKit from '@solana/kit';
|
|
4
|
-
export declare class WalletConnectServiceSolana
|
|
4
|
+
export declare class WalletConnectServiceSolana implements IWalletConnectService<TBSSolanaName> {
|
|
5
5
|
#private;
|
|
6
6
|
static networkIdByNetworkType: Record<TBSSolanaNetworkId, string>;
|
|
7
7
|
readonly namespace = "solana";
|
|
@@ -10,25 +10,25 @@ export declare class WalletConnectServiceSolana<N extends string> implements IWa
|
|
|
10
10
|
readonly supportedEvents: string[];
|
|
11
11
|
readonly calculableMethods: string[];
|
|
12
12
|
readonly autoApproveMethods: string[];
|
|
13
|
-
constructor(service: IBSSolana
|
|
13
|
+
constructor(service: IBSSolana);
|
|
14
14
|
[methodName: string]: any;
|
|
15
|
-
solana_getAccounts(args: TWalletConnectServiceRequestMethodParams<
|
|
15
|
+
solana_getAccounts(args: TWalletConnectServiceRequestMethodParams<TBSSolanaName>): Promise<{
|
|
16
16
|
pubkey: string;
|
|
17
17
|
}[]>;
|
|
18
|
-
solana_requestAccounts(args: TWalletConnectServiceRequestMethodParams<
|
|
18
|
+
solana_requestAccounts(args: TWalletConnectServiceRequestMethodParams<TBSSolanaName>): Promise<{
|
|
19
19
|
pubkey: string;
|
|
20
20
|
}[]>;
|
|
21
|
-
solana_signMessage(args: TWalletConnectServiceRequestMethodParams<
|
|
21
|
+
solana_signMessage(args: TWalletConnectServiceRequestMethodParams<TBSSolanaName>): Promise<{
|
|
22
22
|
signature: string;
|
|
23
23
|
}>;
|
|
24
|
-
solana_signTransaction(args: TWalletConnectServiceRequestMethodParams<
|
|
24
|
+
solana_signTransaction(args: TWalletConnectServiceRequestMethodParams<TBSSolanaName>): Promise<{
|
|
25
25
|
transaction: solanaKit.Base64EncodedWireTransaction;
|
|
26
26
|
}>;
|
|
27
|
-
solana_signAllTransactions(args: TWalletConnectServiceRequestMethodParams<
|
|
27
|
+
solana_signAllTransactions(args: TWalletConnectServiceRequestMethodParams<TBSSolanaName>): Promise<{
|
|
28
28
|
transactions: solanaKit.Base64EncodedWireTransaction[];
|
|
29
29
|
}>;
|
|
30
|
-
solana_signAndSendTransaction(args: TWalletConnectServiceRequestMethodParams<
|
|
30
|
+
solana_signAndSendTransaction(args: TWalletConnectServiceRequestMethodParams<TBSSolanaName>): Promise<{
|
|
31
31
|
signature: solanaKit.Signature;
|
|
32
32
|
}>;
|
|
33
|
-
calculateRequestFee(args: TWalletConnectServiceRequestMethodParams<
|
|
33
|
+
calculateRequestFee(args: TWalletConnectServiceRequestMethodParams<TBSSolanaName>): Promise<string>;
|
|
34
34
|
}
|
|
@@ -92,7 +92,7 @@ class WalletConnectServiceSolana {
|
|
|
92
92
|
throw new Error('Invalid params');
|
|
93
93
|
}
|
|
94
94
|
const parsedTransaction = __classPrivateFieldGet(this, _WalletConnectServiceSolana_instances, "m", _WalletConnectServiceSolana_parseTransaction).call(this, args.params.transaction);
|
|
95
|
-
const signedTransaction = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f").
|
|
95
|
+
const signedTransaction = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f")._signTransaction(parsedTransaction, args.account);
|
|
96
96
|
return { transaction: signedTransaction };
|
|
97
97
|
}
|
|
98
98
|
async solana_signAllTransactions(args) {
|
|
@@ -102,7 +102,7 @@ class WalletConnectServiceSolana {
|
|
|
102
102
|
const signedTransactions = [];
|
|
103
103
|
for (const transaction of args.params.transactions) {
|
|
104
104
|
const parsedTransaction = __classPrivateFieldGet(this, _WalletConnectServiceSolana_instances, "m", _WalletConnectServiceSolana_parseTransaction).call(this, transaction);
|
|
105
|
-
const signedTransaction = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f").
|
|
105
|
+
const signedTransaction = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f")._signTransaction(parsedTransaction, args.account);
|
|
106
106
|
signedTransactions.push(signedTransaction);
|
|
107
107
|
}
|
|
108
108
|
return {
|
|
@@ -115,8 +115,8 @@ class WalletConnectServiceSolana {
|
|
|
115
115
|
}
|
|
116
116
|
const options = args.params.sendOptions ?? {};
|
|
117
117
|
const parsedTransaction = __classPrivateFieldGet(this, _WalletConnectServiceSolana_instances, "m", _WalletConnectServiceSolana_parseTransaction).call(this, args.params.transaction);
|
|
118
|
-
const signedTransaction = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f").
|
|
119
|
-
const signature = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f").
|
|
118
|
+
const signedTransaction = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f")._signTransaction(parsedTransaction, args.account);
|
|
119
|
+
const signature = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f")._solanaKitRpc
|
|
120
120
|
.sendTransaction(signedTransaction, {
|
|
121
121
|
maxRetries: options.maxRetries,
|
|
122
122
|
preflightCommitment: options.preflightCommitment,
|
|
@@ -132,7 +132,7 @@ class WalletConnectServiceSolana {
|
|
|
132
132
|
}
|
|
133
133
|
const transaction = __classPrivateFieldGet(this, _WalletConnectServiceSolana_instances, "m", _WalletConnectServiceSolana_parseTransaction).call(this, args.params.transaction);
|
|
134
134
|
const messageBase64 = solanaKit.getBase64Decoder().decode(transaction.messageBytes);
|
|
135
|
-
const feeResponse = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f").
|
|
135
|
+
const feeResponse = await __classPrivateFieldGet(this, _WalletConnectServiceSolana_service, "f")._solanaKitRpc
|
|
136
136
|
.getFeeForMessage(messageBase64, { commitment: 'confirmed' })
|
|
137
137
|
.send();
|
|
138
138
|
if (!feeResponse.value) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { IBlockchainService, IBSWithExplorer, IBSWithFee, IBSWithLedger, IBSWithNameService, IBSWithNft, IBSWithWalletConnect, TBSAccount, TBSNetworkId } from '@cityofzion/blockchain-service';
|
|
2
2
|
import type { SolanaRpcApi, Rpc, Transaction, Base64EncodedWireTransaction, TransactionForFullJsonParsed } from '@solana/kit';
|
|
3
3
|
export type TBSSolanaNetworkId = TBSNetworkId<'mainnet-beta' | 'devnet'>;
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export type TBSSolanaName = 'solana';
|
|
5
|
+
export interface IBSSolana extends IBlockchainService<TBSSolanaName, TBSSolanaNetworkId>, IBSWithFee<TBSSolanaName>, IBSWithNameService, IBSWithLedger<TBSSolanaName>, IBSWithNft, IBSWithExplorer, IBSWithWalletConnect<TBSSolanaName> {
|
|
6
|
+
_solanaKitRpc: Rpc<SolanaRpcApi>;
|
|
7
|
+
_signTransaction(transaction: Transaction, senderAccount: TBSAccount<TBSSolanaName>): Promise<Base64EncodedWireTransaction>;
|
|
7
8
|
}
|
|
8
9
|
export type TMetaplexAssetByOwnerResponse = {
|
|
9
10
|
jsonrpc: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cityofzion/bs-solana",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5",
|
|
4
4
|
"repository": "https://github.com/CityOfZion/blockchain-services",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Coz",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@solana/kit": "~6.1.0",
|
|
18
18
|
"axios": "~1.13.5",
|
|
19
19
|
"date-fns": "~4.1.0",
|
|
20
|
-
"@cityofzion/blockchain-service": "3.1.
|
|
20
|
+
"@cityofzion/blockchain-service": "3.1.5"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@ledgerhq/hw-transport-node-hid": "~6.30.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"vitest": "~4.0.18"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "rm -rf ./dist && npm run typecheck && tsc --project tsconfig.build.json",
|
|
31
|
+
"build": "rm -rf ./dist && rm -f *.tgz && npm run typecheck && tsc --project tsconfig.build.json",
|
|
32
32
|
"format": "eslint --fix",
|
|
33
33
|
"lint": "eslint .",
|
|
34
34
|
"package": "npm run build && npm pack",
|