@marinade.finance/web3js-1x 4.0.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.
Files changed (83) hide show
  1. package/README.md +75 -0
  2. package/dist/package.json +57 -0
  3. package/dist/src/account.d.ts +38 -0
  4. package/dist/src/account.d.ts.map +1 -0
  5. package/dist/src/account.js +72 -0
  6. package/dist/src/account.js.map +1 -0
  7. package/dist/src/borsh.d.ts +3 -0
  8. package/dist/src/borsh.d.ts.map +1 -0
  9. package/dist/src/borsh.js +31 -0
  10. package/dist/src/borsh.js.map +1 -0
  11. package/dist/src/epoch.d.ts +5 -0
  12. package/dist/src/epoch.d.ts.map +1 -0
  13. package/dist/src/epoch.js +31 -0
  14. package/dist/src/epoch.js.map +1 -0
  15. package/dist/src/equalityTesters.d.ts +2 -0
  16. package/dist/src/equalityTesters.d.ts.map +1 -0
  17. package/dist/src/equalityTesters.js +34 -0
  18. package/dist/src/equalityTesters.js.map +1 -0
  19. package/dist/src/error.d.ts +22 -0
  20. package/dist/src/error.d.ts.map +1 -0
  21. package/dist/src/error.js +65 -0
  22. package/dist/src/error.js.map +1 -0
  23. package/dist/src/execution.d.ts +12 -0
  24. package/dist/src/execution.d.ts.map +1 -0
  25. package/dist/src/execution.js +24 -0
  26. package/dist/src/execution.js.map +1 -0
  27. package/dist/src/fileKeypair.d.ts +7 -0
  28. package/dist/src/fileKeypair.d.ts.map +1 -0
  29. package/dist/src/fileKeypair.js +53 -0
  30. package/dist/src/fileKeypair.js.map +1 -0
  31. package/dist/src/formatter.d.ts +27 -0
  32. package/dist/src/formatter.d.ts.map +1 -0
  33. package/dist/src/formatter.js +113 -0
  34. package/dist/src/formatter.js.map +1 -0
  35. package/dist/src/index.d.ts +19 -0
  36. package/dist/src/index.d.ts.map +1 -0
  37. package/dist/src/index.js +35 -0
  38. package/dist/src/index.js.map +1 -0
  39. package/dist/src/math.d.ts +3 -0
  40. package/dist/src/math.d.ts.map +1 -0
  41. package/dist/src/math.js +19 -0
  42. package/dist/src/math.js.map +1 -0
  43. package/dist/src/parse.d.ts +12 -0
  44. package/dist/src/parse.d.ts.map +1 -0
  45. package/dist/src/parse.js +123 -0
  46. package/dist/src/parse.js.map +1 -0
  47. package/dist/src/provider.d.ts +43 -0
  48. package/dist/src/provider.d.ts.map +1 -0
  49. package/dist/src/provider.js +88 -0
  50. package/dist/src/provider.js.map +1 -0
  51. package/dist/src/solana.d.ts +19 -0
  52. package/dist/src/solana.d.ts.map +1 -0
  53. package/dist/src/solana.js +106 -0
  54. package/dist/src/solana.js.map +1 -0
  55. package/dist/src/stakeAccount.d.ts +22 -0
  56. package/dist/src/stakeAccount.d.ts.map +1 -0
  57. package/dist/src/stakeAccount.js +70 -0
  58. package/dist/src/stakeAccount.js.map +1 -0
  59. package/dist/src/tokenMetadata.d.ts +4 -0
  60. package/dist/src/tokenMetadata.d.ts.map +1 -0
  61. package/dist/src/tokenMetadata.js +14 -0
  62. package/dist/src/tokenMetadata.js.map +1 -0
  63. package/dist/src/tx.d.ts +102 -0
  64. package/dist/src/tx.d.ts.map +1 -0
  65. package/dist/src/tx.js +543 -0
  66. package/dist/src/tx.js.map +1 -0
  67. package/dist/src/txBulk.d.ts +30 -0
  68. package/dist/src/txBulk.d.ts.map +1 -0
  69. package/dist/src/txBulk.js +194 -0
  70. package/dist/src/txBulk.js.map +1 -0
  71. package/dist/src/txToBase64.d.ts +24 -0
  72. package/dist/src/txToBase64.d.ts.map +1 -0
  73. package/dist/src/txToBase64.js +72 -0
  74. package/dist/src/txToBase64.js.map +1 -0
  75. package/dist/src/voteAccount.d.ts +39 -0
  76. package/dist/src/voteAccount.d.ts.map +1 -0
  77. package/dist/src/voteAccount.js +320 -0
  78. package/dist/src/voteAccount.js.map +1 -0
  79. package/dist/src/wallet.d.ts +31 -0
  80. package/dist/src/wallet.d.ts.map +1 -0
  81. package/dist/src/wallet.js +100 -0
  82. package/dist/src/wallet.js.map +1 -0
  83. package/package.json +57 -0
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # web3js-1x
2
+
3
+ [`@marinade.finance/web3js-1x`](https://www.npmjs.com/package/@marinade.finance/web3js-1x)
4
+
5
+ Utilities to work with [Solana web3.js](https://github.com/solana-labs/solana-web3.js/) library
6
+ in **version 1.x**
7
+
8
+ Be aware when working with @solana/web3.js 2.x or @solana/kit use the
9
+ [`@marinade.finance/web3js-kit`](https://github.com/marinade-finance/typescript-common/tree/main/packages/web3js-kit) library.
10
+
11
+ ## Usage
12
+
13
+ ### Pre-requisites
14
+
15
+ The [`@marinade.finance/web3js-1x`](https://www.npmjs.com/package/@marinade.finance/web3js-1x) depends
16
+ on [`@marinade.finance/ts-common`](https://www.npmjs.com/package/@marinade.finance/ts-common) library.
17
+
18
+ ```sh
19
+ pnpm add @marinade.finance/ts-common@latest
20
+ ```
21
+
22
+ ### Dependencies
23
+
24
+ Library defines set of `peerDependencies` that are required to be directly installed by dependent program.
25
+
26
+
27
+ ```sh
28
+ pnpm add @solana/web3.js@1
29
+ pnpm add @marinade.finance/ledger-utils@latest
30
+ pnpm add @solana/buffer-layout@4.0.1
31
+ pnpm add bn.js@5.2.2
32
+ pnpm add borsh@0.7.0
33
+ pnpm add bs58@6.0.0
34
+ ```
35
+
36
+ ### Installation
37
+
38
+ ```sh
39
+ # see Pre-requisites and Dependencies
40
+ pnpm add @marinade.finance/web3js-1x@latest
41
+ ```
42
+
43
+ ## Jest test equality testers
44
+
45
+ When used with testing framework jest to use `equalityTesters`, also install
46
+
47
+ ```sh
48
+ pnpm add -D @jest/globals@^30.1.2
49
+ ```
50
+
51
+ add to `jest.config.js` something like this
52
+
53
+ ```js
54
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
55
+ module.exports = {
56
+ preset: 'ts-jest',
57
+ testEnvironment: 'node',
58
+ testTimeout: 90000,
59
+ detectOpenHandles: true,
60
+ modulePathIgnorePatterns: ['<rootDir>/build/'],
61
+ testPathIgnorePatterns: ['__tests__/.*.skip.ts', '__tests__/setup/*'],
62
+ globalSetup:
63
+ '<rootDir>/packages/marinade-ts-cli/__tests__/setup/globalSetup.ts',
64
+ setupFilesAfterEnv: ['<rootDir>/<path-to-package>/node_modules/@marinade.finance/web3js-1x/dist/src/equalityTesters'],
65
+ }
66
+ ```
67
+
68
+ ## History
69
+
70
+ Before refactoring this library was named as `@marinade.finance/web3js-common`
71
+ and it was published in versions `2.x.x`.
72
+ At the time, the version `@marinade.finance/web3js-common@2` was part of
73
+ the [marinade-ts-cli](https://github.com/marinade-finance/marinade-ts-cli).
74
+ After refactoring it was renamed to `@marinade.finance/web3js-1x` and the versioning started from `4.0.0`.
75
+ See history notes at [`@marinade.finance/web3js-kit`](../web3js-kit/README.md#history).
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@marinade.finance/web3js-1x",
3
+ "version": "4.0.0",
4
+ "description": "solana/web3.js 1.x library tooling for Marinade Finance",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@github.com:marinade-finance/typescript-common.git"
8
+ },
9
+ "main": "dist/src/index.js",
10
+ "types": "dist/src/index.d.ts",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "keywords": [
15
+ "solana",
16
+ "marinade.finance",
17
+ "staking",
18
+ "blockchain",
19
+ "lib"
20
+ ],
21
+ "files": [
22
+ "dist/",
23
+ "!dist/src/__tests__",
24
+ "README.md"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc --build",
28
+ "test": "pnpm jest --config ../../jest.config.js --testPathPattern=\"$(pwd)\""
29
+ },
30
+ "devDependencies": {
31
+ "@marinade.finance/ts-common": "workspace:*",
32
+ "@marinade.finance/ledger-utils": "3.0.1",
33
+ "@solana/web3.js": "1.98.4",
34
+ "@solana/buffer-layout": "4.0.1",
35
+ "bn.js": "5.2.2",
36
+ "borsh": "0.7.0",
37
+ "bs58": "6.0.0",
38
+ "@jest/globals": "^30.1.2"
39
+ },
40
+ "dependencies": {
41
+ "yaml": "2.8.1"
42
+ },
43
+ "peerDependencies": {
44
+ "@marinade.finance/ts-common": "workspace:*",
45
+ "@marinade.finance/ledger-utils": "^3.0.1",
46
+ "@solana/web3.js": "^1.98.4",
47
+ "@solana/buffer-layout": "^4.0.1",
48
+ "bn.js": "^5.2.2",
49
+ "@types/bn.js": "^5.2.0",
50
+ "borsh": "~0.7.0",
51
+ "bs58": "^6.0.0",
52
+ "@jest/globals": "^29 || ^30"
53
+ },
54
+ "engines": {
55
+ "node": ">=20"
56
+ }
57
+ }
@@ -0,0 +1,38 @@
1
+ import { Connection } from '@solana/web3.js';
2
+ import type { Provider } from './provider';
3
+ import type { AccountInfo, GetProgramAccountsFilter, ParsedAccountData, PublicKey } from '@solana/web3.js';
4
+ export type ProgramAccount<T = any> = {
5
+ publicKey: PublicKey;
6
+ account: T;
7
+ };
8
+ export type ProgramAccountInfo<T> = ProgramAccount<AccountInfo<T>>;
9
+ export type ProgramAccountInfoNullable<T> = ProgramAccount<AccountInfo<T> | null>;
10
+ export type ProgramAccountInfoNoData = ProgramAccount<AccountInfo<undefined>>;
11
+ export type ProgramAccountWithInfoNullable<T> = {
12
+ publicKey: PublicKey;
13
+ account: T | null;
14
+ accountInfo: AccountInfo<Buffer> | null;
15
+ };
16
+ export type HasProvider = {
17
+ provider: Provider;
18
+ };
19
+ export declare function isWithPublicKey(account: any): account is {
20
+ publicKey: PublicKey;
21
+ };
22
+ export declare function getConnection(providerOrConnection: Provider | Connection | HasProvider): Connection;
23
+ export declare function programAccountInfo<T>(publicKey: PublicKey, account: AccountInfo<Buffer | ParsedAccountData>, data: T): ProgramAccountInfo<T>;
24
+ export declare function getMultipleAccounts({ connection, addresses, }: {
25
+ connection: HasProvider | Connection | Provider;
26
+ addresses: PublicKey[];
27
+ }): Promise<ProgramAccountInfoNullable<Buffer>[]>;
28
+ export declare function getAccountInfoNoData({ connection, programId, filters, }: {
29
+ connection: HasProvider | Connection | Provider;
30
+ programId: PublicKey;
31
+ filters?: GetProgramAccountsFilter[] | undefined;
32
+ }): Promise<ProgramAccountInfoNoData[]>;
33
+ export declare function getAccountInfoAddresses({ connection, programId, filters, }: {
34
+ connection: HasProvider | Connection | Provider;
35
+ programId: PublicKey;
36
+ filters?: GetProgramAccountsFilter[] | undefined;
37
+ }): Promise<PublicKey[]>;
38
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/account.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,SAAS,EACV,MAAM,iBAAiB,CAAA;AAGxB,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,GAAG,IAAI;IACpC,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,CAAC,CAAA;CACX,CAAA;AACD,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAA;AAClE,MAAM,MAAM,0BAA0B,CAAC,CAAC,IACtC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;AACvC,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAA;AAE7E,MAAM,MAAM,8BAA8B,CAAC,CAAC,IAAI;IAC9C,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,EAAE,CAAC,GAAG,IAAI,CAAA;IACjB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,GAAG,GACX,OAAO,IAAI;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAMrC;AAGD,wBAAgB,aAAa,CAC3B,oBAAoB,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,GACxD,UAAU,CAMZ;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,WAAW,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAChD,IAAI,EAAE,CAAC,GACN,kBAAkB,CAAC,CAAC,CAAC,CAEvB;AAGD,wBAAsB,mBAAmB,CAAC,EACxC,UAAU,EACV,SAAS,GACV,EAAE;IACD,UAAU,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;IAC/C,SAAS,EAAE,SAAS,EAAE,CAAA;CACvB,GAAG,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC,CAsBhD;AAED,wBAAsB,oBAAoB,CAAC,EACzC,UAAU,EACV,SAAS,EACT,OAAO,GACR,EAAE;IACD,UAAU,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;IAC/C,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAA;CACjD,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAgBtC;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,UAAU,EACV,SAAS,EACT,OAAO,GACR,EAAE;IACD,UAAU,EAAE,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;IAC/C,SAAS,EAAE,SAAS,CAAA;IACpB,OAAO,CAAC,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAA;CACjD,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAOvB"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isWithPublicKey = isWithPublicKey;
7
+ exports.getConnection = getConnection;
8
+ exports.programAccountInfo = programAccountInfo;
9
+ exports.getMultipleAccounts = getMultipleAccounts;
10
+ exports.getAccountInfoNoData = getAccountInfoNoData;
11
+ exports.getAccountInfoAddresses = getAccountInfoAddresses;
12
+ const assert_1 = __importDefault(require("assert"));
13
+ const ts_common_1 = require("@marinade.finance/ts-common");
14
+ const web3_js_1 = require("@solana/web3.js");
15
+ function isWithPublicKey(account) {
16
+ return (account !== undefined &&
17
+ account.publicKey !== undefined &&
18
+ account.publicKey !== null);
19
+ }
20
+ function getConnection(providerOrConnection) {
21
+ const connection = 'provider' in providerOrConnection
22
+ ? providerOrConnection.provider
23
+ : providerOrConnection;
24
+ return connection instanceof web3_js_1.Connection ? connection : connection.connection;
25
+ }
26
+ function programAccountInfo(publicKey, account, data) {
27
+ return { publicKey, account: { ...account, data } };
28
+ }
29
+ async function getMultipleAccounts({ connection, addresses, }) {
30
+ if (addresses === undefined || addresses.length === 0) {
31
+ return [];
32
+ }
33
+ const definedConnection = getConnection(connection);
34
+ const result = [];
35
+ for (const addressesChunked of (0, ts_common_1.chunkArray)(addresses, 100)) {
36
+ const fetchedRecords = await definedConnection.getMultipleAccountsInfo(addressesChunked);
37
+ for (const [index, fetchedRecord] of fetchedRecords.entries()) {
38
+ (0, assert_1.default)(addressesChunked[index], 'Solana RPC getMultipleAccountsInfo has to return the same number of accounts as requested');
39
+ result.push({
40
+ publicKey: addressesChunked[index],
41
+ account: fetchedRecord,
42
+ });
43
+ }
44
+ }
45
+ return result;
46
+ }
47
+ async function getAccountInfoNoData({ connection, programId, filters, }) {
48
+ const definedConnection = getConnection(connection);
49
+ const accounts = await definedConnection.getProgramAccounts(programId, {
50
+ dataSlice: { length: 0, offset: 0 },
51
+ filters,
52
+ });
53
+ return accounts.map(d => ({
54
+ publicKey: d.pubkey,
55
+ account: {
56
+ executable: d.account.executable,
57
+ owner: d.account.owner,
58
+ lamports: d.account.lamports,
59
+ rentEpoch: d.account.rentEpoch,
60
+ data: undefined,
61
+ },
62
+ }));
63
+ }
64
+ async function getAccountInfoAddresses({ connection, programId, filters, }) {
65
+ const accounts = await getAccountInfoNoData({
66
+ connection,
67
+ programId,
68
+ filters,
69
+ });
70
+ return accounts.map(d => d.publicKey);
71
+ }
72
+ //# sourceMappingURL=account.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/account.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ export type StringPublicKey = string;
2
+ export declare function extendBorsh(): void;
3
+ //# sourceMappingURL=borsh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"borsh.d.ts","sourceRoot":"","sources":["../../src/borsh.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,eAAe,GAAG,MAAM,CAAA;AACpC,wBAAgB,WAAW,SAqB1B"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extendBorsh = extendBorsh;
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const borsh_1 = require("borsh");
9
+ const bs58_1 = __importDefault(require("bs58"));
10
+ function extendBorsh() {
11
+ ;
12
+ borsh_1.BinaryReader.prototype.readPubkey = function () {
13
+ const reader = this;
14
+ const array = reader.readFixedArray(32);
15
+ return new web3_js_1.PublicKey(array);
16
+ };
17
+ borsh_1.BinaryWriter.prototype.writePubkey = function (value) {
18
+ const writer = this;
19
+ writer.writeFixedArray(value.toBuffer());
20
+ };
21
+ borsh_1.BinaryReader.prototype.readPubkeyAsString = function () {
22
+ const reader = this;
23
+ const array = reader.readFixedArray(32);
24
+ return bs58_1.default.encode(array);
25
+ };
26
+ borsh_1.BinaryWriter.prototype.writePubkeyAsString = function (value) {
27
+ const writer = this;
28
+ writer.writeFixedArray(bs58_1.default.decode(value));
29
+ };
30
+ }
31
+ //# sourceMappingURL=borsh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"borsh.js","sourceRoot":"","sources":["../../src/borsh.ts"],"names":[],"mappings":";;;;;AAOA,kCAqBC;AA1BD,6CAA2C;AAC3C,iCAAkD;AAClD,gDAAyB;AAGzB,SAAgB,WAAW;IACzB,CAAC;IAAC,oBAAY,CAAC,SAAiB,CAAC,UAAU,GAAG;QAC5C,MAAM,MAAM,GAAG,IAA+B,CAAA;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QACvC,OAAO,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC,CACA;IAAC,oBAAY,CAAC,SAAiB,CAAC,WAAW,GAAG,UAAU,KAAgB;QACvE,MAAM,MAAM,GAAG,IAA+B,CAAA;QAC9C,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC1C,CAAC,CACA;IAAC,oBAAY,CAAC,SAAiB,CAAC,kBAAkB,GAAG;QACpD,MAAM,MAAM,GAAG,IAA+B,CAAA;QAC9C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAA;QACvC,OAAO,cAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC,CACA;IAAC,oBAAY,CAAC,SAAiB,CAAC,mBAAmB,GAAG,UACrD,KAAsB;QAEtB,MAAM,MAAM,GAAG,IAA+B,CAAA;QAC9C,MAAM,CAAC,eAAe,CAAC,cAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC9C,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Provider } from './provider';
2
+ import type { Connection } from '@solana/web3.js';
3
+ export declare function waitForEpoch(connection: Connection | Provider, targetEpoch: number, timeoutSeconds: number): Promise<void>;
4
+ export declare function waitForNextEpoch(connection: Connection | Provider, timeoutSeconds: number): Promise<void>;
5
+ //# sourceMappingURL=epoch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epoch.d.ts","sourceRoot":"","sources":["../../src/epoch.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,wBAAsB,YAAY,CAChC,UAAU,EAAE,UAAU,GAAG,QAAQ,EACjC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,iBAqBvB;AAED,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,UAAU,GAAG,QAAQ,EACjC,cAAc,EAAE,MAAM,iBAOvB"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.waitForEpoch = waitForEpoch;
4
+ exports.waitForNextEpoch = waitForNextEpoch;
5
+ const ts_common_1 = require("@marinade.finance/ts-common");
6
+ const provider_1 = require("./provider");
7
+ async function waitForEpoch(connection, targetEpoch, timeoutSeconds) {
8
+ const definedConnection = (0, provider_1.instanceOfProvider)(connection)
9
+ ? connection.connection
10
+ : connection;
11
+ const startTime = Date.now();
12
+ let currentEpoch = (await definedConnection.getEpochInfo()).epoch;
13
+ if (currentEpoch < targetEpoch) {
14
+ console.debug(`Waiting for the epoch ${targetEpoch}, current epoch is ${currentEpoch}`);
15
+ }
16
+ while (currentEpoch < targetEpoch) {
17
+ if (Date.now() - startTime > timeoutSeconds * 1000) {
18
+ throw new Error(`Timeout ${timeoutSeconds} elapsed when waiting for epoch ${targetEpoch} (current epoch: ${currentEpoch})`);
19
+ }
20
+ await (0, ts_common_1.sleep)(1000);
21
+ currentEpoch = (await definedConnection.getEpochInfo()).epoch;
22
+ }
23
+ }
24
+ async function waitForNextEpoch(connection, timeoutSeconds) {
25
+ const definedConnection = (0, provider_1.instanceOfProvider)(connection)
26
+ ? connection.connection
27
+ : connection;
28
+ const currentEpoch = (await definedConnection.getEpochInfo()).epoch;
29
+ await waitForEpoch(definedConnection, currentEpoch + 1, timeoutSeconds);
30
+ }
31
+ //# sourceMappingURL=epoch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epoch.js","sourceRoot":"","sources":["../../src/epoch.ts"],"names":[],"mappings":";;AASA,oCAwBC;AAED,4CASC;AA1CD,2DAAmD;AAEnD,yCAA+C;AAKxC,KAAK,UAAU,YAAY,CAChC,UAAiC,EACjC,WAAmB,EACnB,cAAsB;IAEtB,MAAM,iBAAiB,GAAG,IAAA,6BAAkB,EAAC,UAAU,CAAC;QACtD,CAAC,CAAC,UAAU,CAAC,UAAU;QACvB,CAAC,CAAC,UAAU,CAAA;IACd,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAC5B,IAAI,YAAY,GAAG,CAAC,MAAM,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAA;IACjE,IAAI,YAAY,GAAG,WAAW,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CACX,yBAAyB,WAAW,sBAAsB,YAAY,EAAE,CACzE,CAAA;IACH,CAAC;IACD,OAAO,YAAY,GAAG,WAAW,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,cAAc,GAAG,IAAI,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CACb,WAAW,cAAc,mCAAmC,WAAW,oBAAoB,YAAY,GAAG,CAC3G,CAAA;QACH,CAAC;QACD,MAAM,IAAA,iBAAK,EAAC,IAAI,CAAC,CAAA;QACjB,YAAY,GAAG,CAAC,MAAM,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAA;IAC/D,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,gBAAgB,CACpC,UAAiC,EACjC,cAAsB;IAEtB,MAAM,iBAAiB,GAAG,IAAA,6BAAkB,EAAC,UAAU,CAAC;QACtD,CAAC,CAAC,UAAU,CAAC,UAAU;QACvB,CAAC,CAAC,UAAU,CAAA;IACd,MAAM,YAAY,GAAG,CAAC,MAAM,iBAAiB,CAAC,YAAY,EAAE,CAAC,CAAC,KAAK,CAAA;IACnE,MAAM,YAAY,CAAC,iBAAiB,EAAE,YAAY,GAAG,CAAC,EAAE,cAAc,CAAC,CAAA;AACzE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=equalityTesters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equalityTesters.d.ts","sourceRoot":"","sources":["../../src/equalityTesters.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const globals_1 = require("@jest/globals");
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const bn_js_1 = __importDefault(require("bn.js"));
9
+ globals_1.expect.addEqualityTesters([
10
+ (a, b) => {
11
+ const bnA = convertNumberToBN(a);
12
+ const bnB = convertNumberToBN(b);
13
+ if (bnA instanceof bn_js_1.default) {
14
+ return bnA.eq(bnB);
15
+ }
16
+ return undefined;
17
+ },
18
+ (a, b) => {
19
+ if (a instanceof web3_js_1.PublicKey) {
20
+ return a.equals(b);
21
+ }
22
+ return undefined;
23
+ },
24
+ ]);
25
+ function convertNumberToBN(value) {
26
+ if (typeof value === 'bigint') {
27
+ return new bn_js_1.default(value.toString());
28
+ }
29
+ if (typeof value === 'number') {
30
+ return new bn_js_1.default(value);
31
+ }
32
+ return value;
33
+ }
34
+ //# sourceMappingURL=equalityTesters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equalityTesters.js","sourceRoot":"","sources":["../../src/equalityTesters.ts"],"names":[],"mappings":";;;;;AAAA,2CAAsC;AACtC,6CAA2C;AAC3C,kDAAsB;AAatB,gBAAM,CAAC,kBAAkB,CAAC;IAExB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACP,MAAM,GAAG,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;QAChC,MAAM,GAAG,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;QAChC,IAAI,GAAG,YAAY,eAAE,EAAE,CAAC;YACtB,OAAO,GAAG,CAAC,EAAE,CAAC,GAAS,CAAC,CAAA;QAC1B,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACP,IAAI,CAAC,YAAY,mBAAS,EAAE,CAAC;YAC3B,OAAO,CAAC,CAAC,MAAM,CAAC,CAAc,CAAC,CAAA;QACjC,CAAC;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF,CAAC,CAAA;AAEF,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,eAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;IACjC,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,IAAI,eAAE,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { Transaction, VersionedTransaction } from '@solana/web3.js';
2
+ export declare class ExecutionError extends Error {
3
+ readonly txSignature?: string;
4
+ readonly cause?: Error;
5
+ readonly logs?: string[];
6
+ readonly transaction?: Transaction | VersionedTransaction;
7
+ readonly transactionCauseError?: string;
8
+ constructor({ msg, txSignature, cause, logs, transaction, }: {
9
+ msg?: string;
10
+ txSignature?: string;
11
+ cause?: Error;
12
+ logs?: string[];
13
+ transaction?: Transaction | VersionedTransaction;
14
+ });
15
+ messageWithCause(): string;
16
+ messageWithTransactionError(): string;
17
+ static fromMsg(msg: string): ExecutionError;
18
+ get [Symbol.toStringTag](): string;
19
+ static get [Symbol.species](): typeof ExecutionError;
20
+ private extractTransactionCauseError;
21
+ }
22
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAExE,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,oBAAoB,CAAA;IACzD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAA;gBAE3B,EACV,GAAG,EACH,WAAW,EACX,KAAK,EACL,IAAI,EACJ,WAAW,GACZ,EAAE;QACD,GAAG,CAAC,EAAE,MAAM,CAAA;QACZ,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,KAAK,CAAC,EAAE,KAAK,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;QACf,WAAW,CAAC,EAAE,WAAW,GAAG,oBAAoB,CAAA;KACjD;IAkBD,gBAAgB,IAAI,MAAM;IAK1B,2BAA2B,IAAI,MAAM;IAQrC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;IAI3C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IACD,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,0BAE1B;IAED,OAAO,CAAC,4BAA4B;CAsBrC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExecutionError = void 0;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ class ExecutionError extends Error {
6
+ txSignature;
7
+ cause;
8
+ logs;
9
+ transaction;
10
+ transactionCauseError;
11
+ constructor({ msg, txSignature, cause, logs, transaction, }) {
12
+ super(msg);
13
+ this.txSignature = txSignature;
14
+ this.cause = cause;
15
+ this.logs = logs;
16
+ this.transaction = transaction;
17
+ this.transactionCauseError = this.extractTransactionCauseError(cause);
18
+ const actualProto = new.target.prototype;
19
+ if (Object.setPrototypeOf) {
20
+ Object.setPrototypeOf(this, actualProto);
21
+ }
22
+ else {
23
+ ;
24
+ this.proto = actualProto;
25
+ }
26
+ }
27
+ messageWithCause() {
28
+ const causeMessage = this.cause ? '; caused: ' + this.cause.message : '';
29
+ return this.message + causeMessage;
30
+ }
31
+ messageWithTransactionError() {
32
+ const txCauseErrMessage = this.transactionCauseError
33
+ ? '; transaction error: ' + this.transactionCauseError
34
+ : '';
35
+ const causeMessage = this.cause ? '; caused: ' + this.cause.message : '';
36
+ return this.message + txCauseErrMessage + causeMessage;
37
+ }
38
+ static fromMsg(msg) {
39
+ return new ExecutionError({ msg });
40
+ }
41
+ get [Symbol.toStringTag]() {
42
+ return 'ExecutionError';
43
+ }
44
+ static get [Symbol.species]() {
45
+ return ExecutionError;
46
+ }
47
+ extractTransactionCauseError(error) {
48
+ if (!error || !(error instanceof web3_js_1.SendTransactionError)) {
49
+ return undefined;
50
+ }
51
+ const text = error.message;
52
+ const errorNumberRegex = /Error Number: (\d+)/;
53
+ const errorMessageRegex = /Error Message: ([^.]+)/;
54
+ const errorNumberMatch = text.match(errorNumberRegex);
55
+ const errorMessageMatch = text.match(errorMessageRegex);
56
+ const result = errorMessageMatch && errorMessageMatch[1]
57
+ ? errorMessageMatch[1].trim()
58
+ : undefined;
59
+ return errorNumberMatch
60
+ ? `${result || ''} [err code: ${errorNumberMatch[1]}]`
61
+ : result;
62
+ }
63
+ }
64
+ exports.ExecutionError = ExecutionError;
65
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AAItD,MAAa,cAAe,SAAQ,KAAK;IAC9B,WAAW,CAAS;IACpB,KAAK,CAAQ;IACb,IAAI,CAAW;IACf,WAAW,CAAqC;IAChD,qBAAqB,CAAS;IAEvC,YAAY,EACV,GAAG,EACH,WAAW,EACX,KAAK,EACL,IAAI,EACJ,WAAW,GAOZ;QACC,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAA;QAGrE,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,CAAC,SAAS,CAAA;QACxC,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;QAC1C,CAAC;aAAM,CAAC;YAEN,CAAC;YAAC,IAAY,CAAC,KAAK,GAAG,WAAW,CAAA;QACpC,CAAC;IACH,CAAC;IAED,gBAAgB;QACd,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;QACxE,OAAO,IAAI,CAAC,OAAO,GAAG,YAAY,CAAA;IACpC,CAAC;IAED,2BAA2B;QACzB,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB;YAClD,CAAC,CAAC,uBAAuB,GAAG,IAAI,CAAC,qBAAqB;YACtD,CAAC,CAAC,EAAE,CAAA;QACN,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAA;QACxE,OAAO,IAAI,CAAC,OAAO,GAAG,iBAAiB,GAAG,YAAY,CAAA;IACxD,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAW;QACxB,OAAO,IAAI,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;IACpC,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,gBAAgB,CAAA;IACzB,CAAC;IACD,MAAM,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC;QACzB,OAAO,cAAc,CAAA;IACvB,CAAC;IAEO,4BAA4B,CAClC,KAAwB;QAExB,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK,YAAY,8BAAoB,CAAC,EAAE,CAAC;YACvD,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAA;QAC1B,MAAM,gBAAgB,GAAG,qBAAqB,CAAA;QAC9C,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;QAElD,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;QACrD,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAEvD,MAAM,MAAM,GACV,iBAAiB,IAAI,iBAAiB,CAAC,CAAC,CAAC;YACvC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YAC7B,CAAC,CAAC,SAAS,CAAA;QACf,OAAO,gBAAgB;YACrB,CAAC,CAAC,GAAG,MAAM,IAAI,EAAE,eAAe,gBAAgB,CAAC,CAAC,CAAC,GAAG;YACtD,CAAC,CAAC,MAAM,CAAA;IACZ,CAAC;CACF;AAnFD,wCAmFC"}
@@ -0,0 +1,12 @@
1
+ import { Keypair, PublicKey } from '@solana/web3.js';
2
+ import type { ExtendedProvider, Provider } from './provider';
3
+ import type { Wallet } from './wallet';
4
+ import type { Connection, Signer } from '@solana/web3.js';
5
+ import type BN from 'bn.js';
6
+ export declare function createUserAndFund({ provider, user, lamports, from, }: {
7
+ provider: Connection | Provider | ExtendedProvider;
8
+ user?: Signer | Wallet | Keypair | PublicKey;
9
+ lamports?: number | BN | bigint;
10
+ from?: Signer | Wallet | Keypair;
11
+ }): Promise<Signer | Wallet | Keypair | PublicKey>;
12
+ //# sourceMappingURL=execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/execution.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,SAAS,EAEV,MAAM,iBAAiB,CAAA;AAMxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,OAAO,CAAA;AAE3B,wBAAsB,iBAAiB,CAAC,EACtC,QAAQ,EACR,IAAyB,EACzB,QAA2B,EAC3B,IAAI,GACL,EAAE;IACD,QAAQ,EAAE,UAAU,GAAG,QAAQ,GAAG,gBAAgB,CAAA;IAClD,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;IAC5C,QAAQ,CAAC,EAAE,MAAM,GAAG,EAAE,GAAG,MAAM,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CACjC,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAcjD"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createUserAndFund = createUserAndFund;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const math_1 = require("./math");
6
+ const provider_1 = require("./provider");
7
+ const tx_1 = require("./tx");
8
+ async function createUserAndFund({ provider, user = web3_js_1.Keypair.generate(), lamports = web3_js_1.LAMPORTS_PER_SOL, from, }) {
9
+ const [connection, payer] = (0, provider_1.walletProviderOrConnection)(provider, from);
10
+ const ix = web3_js_1.SystemProgram.transfer({
11
+ fromPubkey: payer.publicKey,
12
+ toPubkey: user instanceof web3_js_1.PublicKey ? user : user.publicKey,
13
+ lamports: (0, math_1.toBigint)(lamports),
14
+ });
15
+ if ('sendIx' in provider) {
16
+ await provider.sendIx([payer], ix);
17
+ }
18
+ else {
19
+ const tx = (await (0, tx_1.transaction)(provider)).add(ix);
20
+ await (0, tx_1.executeTxSimple)(connection, tx, [payer]);
21
+ }
22
+ return user;
23
+ }
24
+ //# sourceMappingURL=execution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/execution.ts"],"names":[],"mappings":";;AAgBA,8CAwBC;AAxCD,6CAKwB;AAExB,iCAAiC;AACjC,yCAAuD;AACvD,6BAAmD;AAO5C,KAAK,UAAU,iBAAiB,CAAC,EACtC,QAAQ,EACR,IAAI,GAAG,iBAAO,CAAC,QAAQ,EAAE,EACzB,QAAQ,GAAG,0BAAgB,EAC3B,IAAI,GAML;IACC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,IAAA,qCAA0B,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IACtE,MAAM,EAAE,GAAG,uBAAa,CAAC,QAAQ,CAAC;QAChC,UAAU,EAAE,KAAK,CAAC,SAAS;QAC3B,QAAQ,EAAE,IAAI,YAAY,mBAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS;QAC3D,QAAQ,EAAE,IAAA,eAAQ,EAAC,QAAQ,CAAC;KAC7B,CAAC,CAAA;IACF,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAA;IACpC,CAAC;SAAM,CAAC;QACN,MAAM,EAAE,GAAG,CAAC,MAAM,IAAA,gBAAW,EAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QAChD,MAAM,IAAA,oBAAe,EAAC,UAAU,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAChD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Keypair } from '@solana/web3.js';
2
+ export declare function createTempFileKeypair(seed?: Keypair, tmpPathPrefix?: string): Promise<{
3
+ path: string;
4
+ cleanup: () => Promise<void>;
5
+ keypair: Keypair;
6
+ }>;
7
+ //# sourceMappingURL=fileKeypair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileKeypair.d.ts","sourceRoot":"","sources":["../../src/fileKeypair.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAEzC,wBAAsB,qBAAqB,CACzC,IAAI,CAAC,EAAE,OAAO,EACd,aAAa,SAAgB,GAC5B,OAAO,CAAC;IACT,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB,CAAC,CAWD"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.createTempFileKeypair = createTempFileKeypair;
37
+ const fs_1 = require("fs");
38
+ const promises_1 = require("fs/promises");
39
+ const os_1 = require("os");
40
+ const path = __importStar(require("path"));
41
+ const web3_js_1 = require("@solana/web3.js");
42
+ async function createTempFileKeypair(seed, tmpPathPrefix = 'tmp-keypair') {
43
+ const keypair = seed ?? new web3_js_1.Keypair();
44
+ const folderPath = path.join((0, os_1.tmpdir)(), tmpPathPrefix);
45
+ const folder = await (0, promises_1.mkdtemp)(folderPath);
46
+ const keypairPath = path.join(folder, 'keypair.json');
47
+ (0, fs_1.writeFileSync)(keypairPath, JSON.stringify(Array.from(keypair.secretKey)));
48
+ const cleanup = async () => {
49
+ await (0, promises_1.rm)(folder, { recursive: true, force: true });
50
+ };
51
+ return { path: keypairPath, cleanup, keypair };
52
+ }
53
+ //# sourceMappingURL=fileKeypair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileKeypair.js","sourceRoot":"","sources":["../../src/fileKeypair.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,sDAkBC;AAzBD,2BAAkC;AAClC,0CAAyC;AACzC,2BAA2B;AAC3B,2CAA4B;AAE5B,6CAAyC;AAElC,KAAK,UAAU,qBAAqB,CACzC,IAAc,EACd,aAAa,GAAG,aAAa;IAM7B,MAAM,OAAO,GAAG,IAAI,IAAI,IAAI,iBAAO,EAAE,CAAA;IAErC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,WAAM,GAAE,EAAE,aAAa,CAAC,CAAA;IACrD,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAO,EAAC,UAAU,CAAC,CAAA;IACxC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACrD,IAAA,kBAAa,EAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IACzE,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE;QACzB,MAAM,IAAA,aAAE,EAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC,CAAA;IACD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;AAChD,CAAC"}
@@ -0,0 +1,27 @@
1
+ export type ReformatAction = {
2
+ type: 'UseExclusively';
3
+ records: {
4
+ key: string;
5
+ value: any;
6
+ }[];
7
+ } | {
8
+ type: 'Remove';
9
+ } | {
10
+ type: 'UsePassThrough';
11
+ };
12
+ export type ObjectFormatterFn = (key: string, value: any) => ReformatAction;
13
+ export interface ObjectFormatterInterface {
14
+ format: ObjectFormatterFn;
15
+ }
16
+ export declare class BaseObjectFormatter implements ObjectFormatterInterface {
17
+ format(_key: string, _value: any): ReformatAction;
18
+ }
19
+ export declare class ChainedKeyNameFormatter extends BaseObjectFormatter {
20
+ readonly formatters: ObjectFormatterFn[];
21
+ constructor(...formatters: ObjectFormatterFn[]);
22
+ format(key: string, value: any): ReformatAction;
23
+ addFormatter(formatter: ObjectFormatterFn): void;
24
+ }
25
+ export declare function reformat(value: any, formatter?: ObjectFormatterFn | BaseObjectFormatter): any;
26
+ export declare function reformatReserved(key: string, value: any): ReformatAction;
27
+ //# sourceMappingURL=formatter.d.ts.map