@debridge-finance/solana-utils 1.0.2
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 +674 -0
- package/README.md +3 -0
- package/dist/browser/index.js +7899 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/cjs/accounts.js +98 -0
- package/dist/cjs/accounts.js.map +1 -0
- package/dist/cjs/constants.js +69 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/crypto.js +108 -0
- package/dist/cjs/crypto.js.map +1 -0
- package/dist/cjs/helpers.js +184 -0
- package/dist/cjs/helpers.js.map +1 -0
- package/dist/cjs/index.js +10 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces.js +9 -0
- package/dist/cjs/interfaces.js.map +1 -0
- package/dist/esm/accounts.js +91 -0
- package/dist/esm/accounts.js.map +1 -0
- package/dist/esm/constants.js +66 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/crypto.js +99 -0
- package/dist/esm/crypto.js.map +1 -0
- package/dist/esm/helpers.js +191 -0
- package/dist/esm/helpers.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces.js +5 -0
- package/dist/esm/interfaces.js.map +1 -0
- package/dist/types/accounts.d.ts +69 -0
- package/dist/types/accounts.d.ts.map +1 -0
- package/dist/types/constants.d.ts +66 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/crypto.d.ts +35 -0
- package/dist/types/crypto.d.ts.map +1 -0
- package/dist/types/helpers.d.ts +27 -0
- package/dist/types/helpers.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interfaces.d.ts +42 -0
- package/dist/types/interfaces.d.ts.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { Connection, Keypair, PublicKey, Signer, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
4
|
+
import { interfaces } from ".";
|
|
5
|
+
export declare function hexToBuffer(data: string, align?: number): Buffer;
|
|
6
|
+
export declare function bufferToHex(data: Buffer | number[] | Uint8Array): string;
|
|
7
|
+
export declare function sleep(milliSeconds: number): Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Serializes transaction and returns serialized size
|
|
10
|
+
* @param transaction tx to get length
|
|
11
|
+
* @param feePayer optional fee payer
|
|
12
|
+
* @returns transaction size
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTransactionSize(transaction: Transaction, feePayer?: PublicKey): number;
|
|
15
|
+
declare type AnyTransaction = Transaction | VersionedTransaction;
|
|
16
|
+
export declare class Wallet implements interfaces.IWallet {
|
|
17
|
+
private keypair;
|
|
18
|
+
publicKey: PublicKey;
|
|
19
|
+
constructor(keypair: Keypair);
|
|
20
|
+
signTransaction(tx: Transaction, additionalSigners?: Signer[]): Promise<Transaction>;
|
|
21
|
+
signAllTransactions(txs: Transaction[], additionalSigners?: (Signer[] | undefined)[]): Promise<Transaction[]>;
|
|
22
|
+
signVersionedTransaction(tx: VersionedTransaction, additionalSigners?: Signer[] | undefined): Promise<VersionedTransaction>;
|
|
23
|
+
signAllVersionedTransactions(txs: VersionedTransaction[], additionalSigners?: (Signer[] | undefined)[] | undefined): Promise<VersionedTransaction[]>;
|
|
24
|
+
}
|
|
25
|
+
export declare function sendAll(connection: Connection, wallet: interfaces.IWallet, transactions: AnyTransaction[], signers?: Keypair[][], waitBetweenSend?: number, skipPreflight?: boolean, debug?: boolean): Promise<string[]>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAA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C,OAAO,EAC1B,YAAY,EAAE,cAAc,EAAE,EAC9B,OAAO,CAAC,EAAE,OAAO,EAAE,EAAE,EACrB,eAAe,CAAC,EAAE,MAAM,EACxB,aAAa,GAAE,OAAe,EAC9B,KAAK,GAAE,OAAe,qBAoFtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,cAAc,YAAY,CAAC;AAC3B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { PublicKey, Signer, Transaction, VersionedTransaction } from "@solana/web3.js";
|
|
4
|
+
import BN from "bn.js";
|
|
5
|
+
export interface IWallet {
|
|
6
|
+
publicKey: PublicKey;
|
|
7
|
+
signTransaction: (tx: Transaction, additionalSigners?: Signer[]) => Promise<Transaction>;
|
|
8
|
+
signAllTransactions: (txs: Transaction[], additionalSigners?: (Signer[] | undefined)[]) => Promise<Transaction[]>;
|
|
9
|
+
signVersionedTransaction?: (tx: VersionedTransaction, additionalSigners?: Signer[]) => Promise<VersionedTransaction>;
|
|
10
|
+
signAllVersionedTransactions?: (txs: VersionedTransaction[], additionalSigners?: (Signer[] | undefined)[]) => Promise<VersionedTransaction[]>;
|
|
11
|
+
}
|
|
12
|
+
export declare function isBuffer(arg: unknown): arg is Buffer;
|
|
13
|
+
export interface HashDeployInfoParams {
|
|
14
|
+
/**
|
|
15
|
+
* Hex-encdoded debridge id
|
|
16
|
+
*/
|
|
17
|
+
debridgeId: string;
|
|
18
|
+
tokenName: string;
|
|
19
|
+
tokenSymbol: string;
|
|
20
|
+
decimals: number;
|
|
21
|
+
}
|
|
22
|
+
export interface AutoParamsType {
|
|
23
|
+
executionFee: BNable;
|
|
24
|
+
flags?: number | Buffer | string;
|
|
25
|
+
/**
|
|
26
|
+
* if 0x prefix exists - hex-encoded string, else Base58-encoded pubkey
|
|
27
|
+
*/
|
|
28
|
+
fallbackAddress: string;
|
|
29
|
+
/**
|
|
30
|
+
* external call data, buffer or hex-encoded string
|
|
31
|
+
*/
|
|
32
|
+
data?: Buffer | HexString;
|
|
33
|
+
shortcut?: Buffer | HexString;
|
|
34
|
+
/**
|
|
35
|
+
* hex-encoded sender
|
|
36
|
+
*/
|
|
37
|
+
nativeSender: string;
|
|
38
|
+
}
|
|
39
|
+
export declare type HexString = string;
|
|
40
|
+
export declare type SolanaPubkey = string | PublicKey;
|
|
41
|
+
export declare type BNable = number | string | BN | Buffer;
|
|
42
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvB,MAAM,WAAW,OAAO;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe,EAAE,CAAC,EAAE,EAAE,WAAW,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;IACzF,mBAAmB,EAAE,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAElH,wBAAwB,CAAC,EAAE,CAAC,EAAE,EAAE,oBAAoB,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACrH,4BAA4B,CAAC,EAAE,CAAC,GAAG,EAAE,oBAAoB,EAAE,EAAE,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,oBAAoB,EAAE,CAAC,CAAC;CAC9I;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAEpD;AAED,MAAM,WAAW,oBAAoB;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,cAAc;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,oBAAY,SAAS,GAAG,MAAM,CAAC;AAC/B,oBAAY,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAC9C,oBAAY,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,EAAE,GAAG,MAAM,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@debridge-finance/solana-utils",
|
|
3
|
+
"description": "Common utils package to power communication with Solana contracts at deBridge",
|
|
4
|
+
"version": "1.0.2",
|
|
5
|
+
"author": "deBridge",
|
|
6
|
+
"license": "GPL-3.0-only",
|
|
7
|
+
"homepage": "https://debridge.finance",
|
|
8
|
+
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "github:debridge-finance/solana-utils"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"solana",
|
|
15
|
+
"deBridge",
|
|
16
|
+
"blockchain"
|
|
17
|
+
],
|
|
18
|
+
|
|
19
|
+
"main": "./dist/cjs/index.js",
|
|
20
|
+
"module": "dist/esm/index.js",
|
|
21
|
+
"types": "./dist/types/index",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"import": "./dist/esm/index.js",
|
|
26
|
+
"require": "./dist/cjs/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/**",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test:crypto": "mocha -r ts-node/register -b -t 200000 ./tests/crypto.test.ts",
|
|
36
|
+
"test:accounts": "mocha -r ts-node/register -b -t 200000 ./tests/accounts.test.ts",
|
|
37
|
+
"lint:fix": "prettier src/** tests/** -w",
|
|
38
|
+
"lint": "prettier src/** tests/** --check",
|
|
39
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
40
|
+
"build:node": "tsc -p tsconfig.cjs.json",
|
|
41
|
+
"build:browser": "rollup -c",
|
|
42
|
+
"build": "rimraf dist && npm run build:esm && npm run build:node && npm run build:browser"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@solana/web3.js": "1.62.0",
|
|
46
|
+
"bn.js": "5.2.1",
|
|
47
|
+
"buffer": "6.0.3",
|
|
48
|
+
"ethers": "5.7.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@rollup/plugin-commonjs": "^22.0.2",
|
|
52
|
+
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
53
|
+
"@rollup/plugin-replace": "^4.0.0",
|
|
54
|
+
"@rollup/plugin-typescript": "^8.5.0",
|
|
55
|
+
"@types/bn.js": "^5.1.1",
|
|
56
|
+
"@types/chai": "^4.3.3",
|
|
57
|
+
"@types/mocha": "^9.1.1",
|
|
58
|
+
"@types/node": "^18.7.18",
|
|
59
|
+
"@typescript-eslint/eslint-plugin": "^5.37.0",
|
|
60
|
+
"@typescript-eslint/parser": "^5.37.0",
|
|
61
|
+
"assert": "^2.0.0",
|
|
62
|
+
"eslint": "^8.23.1",
|
|
63
|
+
"eslint-config-prettier": "^8.5.0",
|
|
64
|
+
"mocha": "^10.0.0",
|
|
65
|
+
"prettier": "^2.7.1",
|
|
66
|
+
"rimraf": "^3.0.2",
|
|
67
|
+
"rollup": "^2.79.1",
|
|
68
|
+
"ts-node": "^10.9.1",
|
|
69
|
+
"tslib": "^2.4.0"
|
|
70
|
+
}
|
|
71
|
+
}
|