diff --git a/__tests__/08.custom-network.ava.ts b/__tests__/08.custom-network.ava.ts new file mode 100644 index 00000000..2fc01a35 --- /dev/null +++ b/__tests__/08.custom-network.ava.ts @@ -0,0 +1,40 @@ +import process from 'process'; +import {Worker, getNetworkFromEnv} from 'near-workspaces'; +import anyTest, {TestFn} from 'ava'; + +// To run this test, you need to set the NEAR_RPC_API_KEY environment variable tied the Pagoda testnet network. +// And the NEAR_WORKSPACES_NETWORK environment variable to 'custom'. +// +// Sample: NEAR_WORKSPACES_NETWORK=custom NEAR_RPC_API_KEY="xxx" yarn test... +if (getNetworkFromEnv() === 'custom' && process.env.NEAR_RPC_API_KEY !== '') { + const test = anyTest as TestFn<{ + worker: Worker; + }>; + + test.before(async t => { + const worker = await Worker.init({ + network: 'custom', + rpcAddr: 'https://near-testnet.api.pagoda.co/rpc/v1/', + apiKey: process.env.NEAR_RPC_API_KEY!, + }); + t.context.worker = worker; + }); + + test.after.always(async t => { + await t.context.worker.tearDown().catch(error => { + console.log('Failed to tear down the worker:', error); + }); + }); + + test('Ping network', async t => { + try { + await t.context.worker.provider.block({finality: 'final'}); + } catch (error: unknown) { + t.fail(`Failed to ping the network: ${error as string}`); + return; + } + + t.pass('Network pinged successfully!'); + }); +} + diff --git a/packages/js/dist/account/account-manager.d.ts b/packages/js/dist/account/account-manager.d.ts index 3e627797..ab2d87e4 100644 --- a/packages/js/dist/account/account-manager.d.ts +++ b/packages/js/dist/account/account-manager.d.ts @@ -46,6 +46,14 @@ export declare abstract class AccountManager implements NearAccountManager { protected get networkId(): string; protected get connection(): nearAPI.Connection; } +export declare class CustomnetManager extends AccountManager { + get DEFAULT_INITIAL_BALANCE(): string; + get defaultKeyStore(): KeyStore; + get connection(): nearAPI.Connection; + get networkId(): string; + init(): Promise; + createFrom(config: Config): Promise; +} export declare class TestnetManager extends AccountManager { static readonly KEYSTORE_PATH: string; private static numTestAccounts; diff --git a/packages/js/dist/account/account-manager.d.ts.map b/packages/js/dist/account/account-manager.d.ts.map index 0741580d..1245c6e6 100644 --- a/packages/js/dist/account/account-manager.d.ts.map +++ b/packages/js/dist/account/account-manager.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"account-manager.d.ts","sourceRoot":"","sources":["../../src/account/account-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,EAAC,MAAM,EAAE,OAAO,EAAE,EAAE,EAAyC,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,UAAU,CAAC;AAEpJ,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AAE1D,8BAAsB,cAAe,YAAW,kBAAkB;IAI9D,SAAS,CAAC,MAAM,EAAE,MAAM;IAH1B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IACzC,OAAO,CAAC,KAAK,CAAC,CAAc;gBAEhB,MAAM,EAAE,MAAM;IAG1B,MAAM,CAAC,MAAM,CACX,MAAM,EAAE,MAAM,GACb,cAAc;IAWX,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI1D,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW;IAI1C,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW;IAS1C,SAAS,CACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC;IASV,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC;IAIrC,IAAI,IAAI,IAAI,WAAW,CAMtB;IAED,IAAI,cAAc,IAA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;CAQ9D"} \ No newline at end of file diff --git a/packages/js/dist/account/account-manager.js b/packages/js/dist/account/account-manager.js index c15230bd..6a2ff7b2 100644 --- a/packages/js/dist/account/account-manager.js +++ b/packages/js/dist/account/account-manager.js @@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.ManagedTransaction = exports.SandboxManager = exports.TestnetManager = exports.AccountManager = void 0; +exports.ManagedTransaction = exports.SandboxManager = exports.TestnetManager = exports.CustomnetManager = exports.AccountManager = void 0; const path = __importStar(require("path")); const process = __importStar(require("process")); const nearAPI = __importStar(require("near-api-js")); @@ -48,7 +48,9 @@ class AccountManager { return new SandboxManager(config); case 'testnet': return new TestnetManager(config); - default: throw new Error(`Bad network id: "${network}"; expected "testnet" or "sandbox"`); + case 'custom': + return new CustomnetManager(config); + default: throw new Error(`Bad network id: "${network}"; expected "testnet", "custom" or "sandbox"`); } } async accountView(accountId) { @@ -204,6 +206,27 @@ class AccountManager { } } exports.AccountManager = AccountManager; +class CustomnetManager extends AccountManager { + get DEFAULT_INITIAL_BALANCE() { + return near_units_1.NEAR.parse('10 N').toJSON(); + } + get defaultKeyStore() { + return new nearAPI.keyStores.InMemoryKeyStore(); + } + get connection() { + return new nearAPI.Connection(this.networkId, this.provider, this.signer, `jsvm.${this.networkId}`); + } + get networkId() { + return this.config.network; + } + async init() { + return this; + } + async createFrom(config) { + return new CustomnetManager(config); + } +} +exports.CustomnetManager = CustomnetManager; class TestnetManager extends AccountManager { static get defaultKeyStore() { const keyStore = new nearAPI.keyStores.UnencryptedFileSystemKeyStore(this.KEYSTORE_PATH); diff --git a/packages/js/dist/account/account-manager.js.map b/packages/js/dist/account/account-manager.js.map index 23c39fb9..d546c744 100644 --- a/packages/js/dist/account/account-manager.js.map +++ b/packages/js/dist/account/account-manager.js.map @@ -1 +1 @@ -{"version":3,"file":"account-manager.js","sourceRoot":"","sources":["../../src/account/account-manager.ts"],"names":[],"mappings":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oB,CAAC,CAAC;IAC9D,CAAC;CACF;AA3BD,wCA2BC;AAED,MAAa,kBAAmB,SAAQ,yBAAW;IAEjD,YAA6B,OAAuB,EAAE,MAA6B,EAAE,QAA+B;QAClH,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QADG,YAAO,GAAP,OAAO,CAAgB;QAD5C,WAAM,GAAG,KAAK,CAAC;IAGvB,CAAC;IAED,aAAa;QACX,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC/D,OAAO,KAAK,CAAC,aAAa,EAAE,CAAC;IAC/B,CAAC;IAED,aAAa,CAAC,aAAqB;QACjC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,OAAO,KAAK,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,OAAiB;QAC9B,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7E,IAAI,eAAe,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,EAAE;YAC5C,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC/C;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AA7BD,gDA6BC"} \ No newline at end of file +{"version":3,"file":"account-manager.js","sourceRoot":"","sources":["../../src/account/account-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,iDAAmC;AACnC,qDAAuC;AACvC,2CAAgC;AAChC,oCAAkE;AAClE,oCAAoJ;AACpJ,sDAAiD;AACjD,gDAA2C;AAC3C,wCAA2C;AAC3C,8DAAwD;AACxD,uCAAkC;AAElC,mCAAuC;AAGvC,MAAsB,cAAc;IAGlC,YACY,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AS,IAAI,IAAI,CAAC,MAAM,EAAE;YAC5C,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SAC/C;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AA7BD,gDA6BC"} \ No newline at end of file diff --git a/packages/js/dist/jsonrpc.d.ts b/packages/js/dist/jsonrpc.d.ts index 08e8bd73..7eafcf6d 100644 --- a/packages/js/dist/jsonrpc.d.ts +++ b/packages/js/dist/jsonrpc.d.ts @@ -127,7 +127,7 @@ export declare class JsonRpcProvider extends JSONRpc { * to wait a fraction of the time it takes to produce the same number of blocks. * * Estimate as to how long it takes: if our delta_height crosses `X` epochs, then it would - * roughly take `X * 5` seconds for the fast forward request to be processed. + * roughly take `X * 5` milliseconds for the fast forward request to be processed. * * Note: This is not to be confused with speeding up the current in-flight transactions; * the state being forwarded in this case refers to time-related state (the block height, timestamp and epoch). diff --git a/packages/js/dist/jsonrpc.js b/packages/js/dist/jsonrpc.js index aa6e79b7..09fb8467 100644 --- a/packages/js/dist/jsonrpc.js +++ b/packages/js/dist/jsonrpc.js @@ -175,7 +175,7 @@ class JsonRpcProvider extends types_1.JSONRpc { * to wait a fraction of the time it takes to produce the same number of blocks. * * Estimate as to how long it takes: if our delta_height crosses `X` epochs, then it would - * roughly take `X * 5` seconds for the fast forward request to be processed. + * roughly take `X * 5` milliseconds for the fast forward request to be processed. * * Note: This is not to be confused with speeding up the current in-flight transactions; * the state being forwarded in this case refers to time-related state (the block height, timestamp and epoch). diff --git a/packages/js/dist/types.d.ts b/packages/js/dist/types.d.ts index 40f9cac4..94e61dc7 100644 --- a/packages/js/dist/types.d.ts +++ b/packages/js/dist/types.d.ts @@ -32,12 +32,13 @@ export interface AccountBalance { staked: NEAR; available: NEAR; } -export type Network = 'testnet' | 'mainnet' | 'sandbox'; +export type Network = 'testnet' | 'mainnet' | 'sandbox' | 'custom'; export interface ClientConfig { network: Network; rootAccountId?: string; testnetMasterAccountId?: string; rpcAddr: string; + apiKey?: string; helperUrl?: string; explorerUrl?: string; initialBalance?: string; diff --git a/packages/js/dist/types.d.ts.map b/packages/js/dist/types.d.ts.map index 30491e9f..c442bc8e 100644 --- a/packages/js/dist/types.d.ts.map +++ b/packages/js/dist/types.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAC3C,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAC,OAAO,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EACL,MAAM,EACN,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,MAAM,EACN,SAAS,EACT,aAAa,EACb,aAAa,EACb,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,eAAe,IAAI,OAAO,EAAC,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAC,QAAQ,EAAC,MAAM,4BAA4B,CAAC;AACpD,cAAc,oCAAoC,CAAC;AAEnD,OAAO,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AAEpE,qBAAa,EAAG,SAAQ,GAAG;IACzB,MAAM,IAAI,MAAM;CAGjB;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC;AAEpD,MAAM,W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AE,CAAC;CACjB;AAED,MAAM,MAAM,KAAK,GAAG,EAAE,CAAC"} \ No newline at end of file diff --git a/packages/js/dist/types.js.map b/packages/js/dist/types.js.map index b32f6e0d..7ed14faa 100644 --- a/packages/js/dist/types.js.map +++ b/packages/js/dist/types.js.map @@ -1 +1 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,kDAAwB;AAMxB,+DAA6D;AAArD,yGAAA,WAAW,OAAA;AACnB,2CAAgD;AAAxC,sGAAA,OAAO,OAAA;AAAE,yGAAA,UAAU,OAAA;AAC3B,+CAAgE;AAAxD,kGAAA,SAAS,OAAA;AAAE,uGAAA,cAAc,OAAA;AACjC,2DAYqC;AAXnC,qGAAA,MAAM,OAAA;AACN,4GAAA,aAAa,OAAA;AACb,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,uGAAA,QAAQ,OAAA;AACR,oGAAA,KAAK,OAAA;AACL,qGAAA,MAAM,OAAA;AACN,wGAAA,SAAS,OAAA;AACT,4GAAA,aAAa,OAAA;AACb,4GAAA,aAAa,OAAA;AACb,wGAAA,SAAS,OAAA;AAGX,iFAAuF;AAA/E,4GAAA,eAAe,OAAW;AAClC,yDAAoD;AAA5C,sGAAA,QAAQ,OAAA;AAChB,qEAAmD;AAEnD,uDAAoE;AAA5D,sHAAA,yBAAyB,OAAA;AAEjC,MAAa,EAAG,SAAQ,eAAG;IACzB,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;CACF;AAJD,gBAIC;AA6CY,QAAA,gBAAgB,GAAG,uCAAuC,CAAC;AAC3D,QAAA,gBAAgB,GAAG,uCAAuC,CAAC"} \ No newline at end of file +{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,kDAAwB;AAMxB,+DAA6D;AAArD,yGAAA,WAAW,OAAA;AACnB,2CAAgD;AAAxC,sGAAA,OAAO,OAAA;AAAE,yGAAA,UAAU,OAAA;AAC3B,+CAAgE;AAAxD,kGAAA,SAAS,OAAA;AAAE,uGAAA,cAAc,OAAA;AACjC,2DAYqC;AAXnC,qGAAA,MAAM,OAAA;AACN,4GAAA,aAAa,OAAA;AACb,6GAAA,cAAc,OAAA;AACd,2GAAA,YAAY,OAAA;AACZ,uGAAA,QAAQ,OAAA;AACR,oGAAA,KAAK,OAAA;AACL,qGAAA,MAAM,OAAA;AACN,wGAAA,SAAS,OAAA;AACT,4GAAA,aAAa,OAAA;AACb,4GAAA,aAAa,OAAA;AACb,wGAAA,SAAS,OAAA;AAGX,iFAAuF;AAA/E,4GAAA,eAAe,OAAW;AAClC,yDAAoD;AAA5C,sGAAA,QAAQ,OAAA;AAChB,qEAAmD;AAEnD,uDAAoE;AAA5D,sHAAA,yBAAyB,OAAA;AAEjC,MAAa,EAAG,SAAQ,eAAG;IACzB,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;CACF;AAJD,gBAIC;AA8CY,QAAA,gBAAgB,GAAG,uCAAuC,CAAC;AAC3D,QAAA,gBAAgB,GAAG,uCAAuC,CAAC"} \ No newline at end of file diff --git a/packages/js/dist/utils.d.ts b/packages/js/dist/utils.d.ts index ff892a7c..4bee558a 100644 --- a/packages/js/dist/utils.d.ts +++ b/packages/js/dist/utils.d.ts @@ -13,6 +13,7 @@ export declare function captureError(fn: () => Promise): Promise; export declare function isTopLevelAccount(accountId: string): boolean; export declare function urlConfigFromNetwork(network: string | { network: string; + rpcAddr?: string; }): ClientConfig; /** * @@ -25,7 +26,7 @@ export declare const EMPTY_CONTRACT_HASH = "11111111111111111111111111111111"; * * @returns network to connect to. Default 'sandbox' */ -export declare function getNetworkFromEnv(): 'sandbox' | 'testnet'; +export declare function getNetworkFromEnv(): 'sandbox' | 'testnet' | 'custom'; export declare function homeKeyStore(): KeyStore; export declare function timeSuffix(prefix: string, length?: number): string; export declare function parseGas(s: string | BN): Gas; diff --git a/packages/js/dist/utils.d.ts.map b/packages/js/dist/utils.d.ts.map index 1cec7cd8..287d7ae6 100644 --- a/packages/js/dist/utils.d.ts.map +++ b/packages/js/dist/utils.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAO9B,OAAO,EAAC,GAAG,EAAE,IAAI,EAAC,MAAM,YAAY,CAAC;AACrC,OAAO,EAAC,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAC,MAAM,SAAS,CAAC;AAE1E,eAAO,MAAM,QAAQ,MAAmB,CAAC;AAEzC,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,UAQtC;AAGD,wBAAgB,eAAe,CAAC,MAAM,SAAS,EAAE,UAAU,SAAK,EAAE,YAAY,SAAK,GAAG,MAAM,CAG3F;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,MAAM,CAEtD;AAED,eAAO,MAAM,UAAU,MAAe,CAAC;AAEvC,wBAAsB,YAAY,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAU1E;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAE5D;AAoBD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,GAAG,YAAY,CActF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,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AAE,MAAM,GAAG,OAAO,CAE5D;AAoBD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG,YAAY,CAqBxG;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAI9D;AAED,eAAO,MAAM,mBAAmB,qCAAqC,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,GAAG,SAAS,GAAG,QAAQ,CAepE;AAED,wBAAgB,YAAY,IAAI,QAAQ,CAIvC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,SAAI,GAAG,MAAM,CAE7D;AAID,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,GAAG,GAAG,CAM5C;AAID,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,EAAE,GAAG,IAAI,CAM9C"} \ No newline at end of file diff --git a/packages/js/dist/utils.js b/packages/js/dist/utils.js index 2fdba77e..1a468567 100644 --- a/packages/js/dist/utils.js +++ b/packages/js/dist/utils.js @@ -97,16 +97,22 @@ function configFromDomain(network) { } function urlConfigFromNetwork(network) { const networkName = typeof network === 'string' ? network : network.network; + const rpcAddr = typeof network === 'string' ? undefined : network.rpcAddr; switch (networkName) { case 'sandbox': return { network: 'sandbox', rpcAddr: 'http://localhost', }; + case 'custom': + return { + network: 'custom', + rpcAddr: rpcAddr, + }; case 'testnet': case 'mainnet': return configFromDomain(networkName); default: - throw new Error(`Got network ${networkName}, but only accept 'sandbox', 'testnet', and 'mainnet'`); + throw new Error(`Got network ${networkName}, but only accept 'sandbox', 'testnet', 'mainnet' and 'custom'`); } } exports.urlConfigFromNetwork = urlConfigFromNetwork; @@ -131,12 +137,13 @@ function getNetworkFromEnv() { switch (network) { case 'sandbox': case 'testnet': + case 'custom': return network; case undefined: return 'sandbox'; default: throw new Error(`environment variable NEAR_WORKSPACES_NETWORK=${network} invalid; ` - + 'use \'testnet\', or \'sandbox\' (the default)'); + + 'use \'testnet\', \'custom\', or \'sandbox\' (the default)'); } } exports.getNetworkFromEnv = getNetworkFromEnv; diff --git a/packages/js/dist/utils.js.map b/packages/js/dist/utils.js.map index 5ab2e1a4..a760197b 100644 --- a/packages/js/dist/utils.js.map +++ b/packages/js/dist/utils.js.map @@ -1 +1 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA8B;AAC9B,iDAAmC;AACnC,uCAAyB;AACzB,2CAA6B;AAC7B,qDAAuC;AACvC,0DAA+B;AAC/B,gDAAwB;AACxB,2CAAqC;AAGxB,QAAA,QAAQ,GAAG,iBAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAEzC,SAAgB,OAAO,CAAC,MAAc;IACpC,OAAO,iBAAI,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC7C,CAAC;AAFD,0BAEC;AAED,SAAgB,aAAa;IAC3B,OAAO,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;AACnD,CAAC;AAFD,sCAEC;AAED,SAAgB,IAAI,CAAC,CAAkB;IACrC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE;QACjE,MAAM,IAAI,SAAS,CACjB,uDAAuD,CAAC,EAAE,CAC3D,CAAC;KACH;IAED,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACpC,CAAC;AARD,oBAQC;AAED,2DAA2D;AAC3D,SAAgB,eAAe,CAAC,MAAM,GAAG,M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/js/dist/worker.d.ts +++ b/packages/js/dist/worker.d.ts @@ -27,6 +27,13 @@ export declare abstract class Worker { abstract get provider(): JsonRpcProvider; abstract tearDown(): Promise; } +export declare class CustomnetWorker extends Worker { + private readonly clientConfig; + static init(config: Partial): Promise; + get provider(): JsonRpcProvider; + tearDown(): Promise; + get defaultConfig(): Config; +} export declare class TestnetWorker extends Worker { static init(config: Partial): Promise; get provider(): JsonRpcProvider; diff --git a/packages/js/dist/worker.d.ts.map b/packages/js/dist/worker.d.ts.map index 8e170940..e59a7ca3 100644 --- a/packages/js/dist/worker.d.ts.map +++ b/packages/js/dist/worker.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAe,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAiB,WAAW,EAAE,kBAAkB,EAAC,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAI1C;;GAEG;AACH,8BAAsB,MAAM;IAC1B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAEzB,SAAS,CAAC,OAAO,EAAG,kBAAkB,CAAC;gBAE3B,MAAM,EAAE,MAAM;IAM1B;;;;;;;;;;;;;OAaG;WACU,IAAI,CAAC,MAAM,GAAE,OAAO,CAAC,MAAM,CAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAehE,IAAI,WAAW,IAAI,WAAW,CAE7B;IAED,QAAQ,KAAK,QAAQ,IAAI,eAAe,CAAC;IAEzC,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CACnC;AAED,qBAAa,aAAc,SAAQ,MAAM;WAC1B,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAQlE,IAAI,QAAQ,IAAI,eAAe,CAE9B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,C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,OAAO,CAAC,eAAe,CAAC;IAsBpE,IAAI,QAAQ,IAAI,eAAe,CAE9B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,IAAI,aAAa,IAAI,MAAM,CAQ1B;CACF;AAED,qBAAa,aAAc,SAAQ,MAAM;WAC1B,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAelE,IAAI,QAAQ,IAAI,eAAe,CAE9B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAK/B,MAAM,KAAK,aAAa,IAAI,MAAM,CAQjC;IAED,OAAO,CAAC,MAAM,KAAK,YAAY,GAE9B;CACF;AAED,qBAAa,aAAc,SAAQ,MAAM;IACvC,OAAO,CAAC,MAAM,CAAiB;WAElB,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;WAsCrD,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAY7C,IAAI,QAAQ,IAAI,eAAe,CAE9B;IAEK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ/B,OAAO,CAAC,MAAM,KAAK,YAAY,GAO9B;IAED,OAAO,KAAK,OAAO,GAElB;CACF"} \ No newline at end of file diff --git a/packages/js/dist/worker.js b/packages/js/dist/worker.js index aaddbe89..6ca8cfa3 100644 --- a/packages/js/dist/worker.js +++ b/packages/js/dist/worker.js @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.SandboxWorker = exports.TestnetWorker = exports.Worker = void 0; +exports.SandboxWorker = exports.TestnetWorker = exports.CustomnetWorker = exports.Worker = void 0; const fs_1 = __importDefault(require("fs")); const near_units_1 = require("near-units"); const proper_lockfile_1 = require("proper-lockfile"); @@ -12,6 +12,7 @@ const account_1 = require("./account"); const jsonrpc_1 = require("./jsonrpc"); const internal_utils_1 = require("./internal-utils"); const server_1 = require("./server/server"); +const API_KEY_HEADER = 'x-api-key'; /** * The main interface to near-workspaces. Create a new worker instance with {@link Worker.init}, then run code on it. */ @@ -43,9 +44,11 @@ class Worker { return TestnetWorker.init(config); case 'sandbox': return SandboxWorker.init(config); + case 'custom': + return CustomnetWorker.init(config); default: throw new Error(`config.network = '${config.network}' invalid; ` // eslint-disable-line @typescript-eslint/restrict-template-expressions - + 'must be \'testnet\' or \'sandbox\' (the default). Soon \'mainnet\''); + + 'must be \'testnet\', \'sandbox\' or \'custom\' (the default). Soon \'mainnet\''); } } get rootAccount() { @@ -53,11 +56,60 @@ class Worker { } } exports.Worker = Worker; +// Connect to a custom network. +// Note: the burden of ensuring the methods that are able to be called are left up to the user. +class CustomnetWorker extends Worker { + constructor() { + super(...arguments); + this.clientConfig = (0, utils_1.urlConfigFromNetwork)({ network: 'custom', rpcAddr: this.config.rpcAddr }); + } + static async init(config) { + (0, internal_utils_1.debug)('Lifecycle.CustomnetWorker.create()', 'config:', config); + const fullConfig = { + homeDir: 'ignored', + port: 3030, + rm: false, + refDir: null, + ...(0, utils_1.urlConfigFromNetwork)({ network: 'custom', rpcAddr: config.rpcAddr }), + ...config, + }; + const worker = new CustomnetWorker(fullConfig); + if (config.apiKey) { + worker.provider.connection.headers = { + ...worker.provider.connection.headers, [API_KEY_HEADER]: config.apiKey, + }; + } + await worker.manager.init(); + return worker; + } + get provider() { + return jsonrpc_1.JsonRpcProvider.from(this.clientConfig); + } + async tearDown() { + // We are not stopping any server here because it is an external network. + return Promise.resolve(); + } + get defaultConfig() { + return { + homeDir: 'ignored', + port: 3030, + rm: false, + refDir: null, + ...this.clientConfig, + }; + } +} +exports.CustomnetWorker = CustomnetWorker; class TestnetWorker extends Worker { static async init(config) { (0, internal_utils_1.debug)('Lifecycle.TestnetWorker.create()', 'config:', config); const fullConfig = { ...this.defaultConfig, ...config }; const worker = new TestnetWorker(fullConfig); + if (config.apiKey) { + worker.provider.connection.headers = { + ...worker.provider.connection.headers, [API_KEY_HEADER]: config.apiKey, + }; + } await worker.manager.init(); return worker; } @@ -106,6 +158,11 @@ class SandboxWorker extends Worker { const release = await (0, proper_lockfile_1.lock)(syncFilename, retryOptions); const defaultConfig = await this.defaultConfig(); const worker = new SandboxWorker({ ...defaultConfig, ...config }); + if (config.apiKey) { + worker.provider.connection.headers = { + ...worker.provider.connection.headers, [API_KEY_HEADER]: config.apiKey, + }; + } worker.server = await server_1.SandboxServer.init(worker.config); await worker.server.start(); // Release file lock after near node start diff --git a/packages/js/dist/worker.js.map b/packages/js/dist/worker.js.map index 1abd30d7..a5016dfd 100644 --- a/packages/js/dist/worker.js.map +++ b/packages/js/dist/worker.js.map @@ -1 +1 @@ -{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,2CAAgC;AAChC,qDAAqC;AACrC,mCAAgE;AAEhE,uCAA0E;AAC1E,uCAA0C;AAC1C,qDAAuC;AACvC,4CAA8C;AAE9C;;GAEG;AACH,MAAsB,MAAM;IAK1B,YAAY,MAAc;QACxB,IAAA,sBAAK,EAAC,8BAA8B,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,wBAAc,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAA0B,EAAE;;QAC5C,IAAA,sBAAK,EAAC,yBAAyB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QACpD,QAAQ,MAAA,MAAM,CAAC,OAAO,mCAAI,IAAA,yBAAiB,GAAE,EAAE;YAC7C,KAAK,SAAS;gBACZ,OAAO,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpC,KAAK,SAAS;gBACZ,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,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI;YACF,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;SAC3B;QAAC,OAAO,KAAc,EAAE;YACvB,IAAA,sBAAK,EAAC,kCAAkC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;SAC3E;IACH,CAAC;IAEO,MAAM,KAAK,YAAY;QAC7B,OAAO;YACL,OAAO,EAAE,SAAS;YAClB,aAAa,EAAE,WAAW;YAC1B,OAAO,EAAE,EAAE;YACX,cAAc,EAAE,iBAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;SAC7C,CAAC;IACJ,CAAC;IAED,IAAY,OAAO;QACjB,OAAO,oBAAoB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAChD,CAAC;CACF;AA7ED,sCA6EC"} \ No newline at end of file diff --git a/packages/js/src/account/account-manager.ts b/packages/js/src/account/account-manager.ts index 2cc9485e..0db38ac2 100644 --- a/packages/js/src/account/account-manager.ts +++ b/packages/js/src/account/account-manager.ts @@ -29,7 +29,9 @@ export abstract class AccountManager implements NearAccountManager { return new SandboxManager(config); case 'testnet': return new TestnetManager(config); - default: throw new Error(`Bad network id: "${network as string}"; expected "testnet" or "sandbox"`); + case 'custom': + return new CustomnetManager(config); + default: throw new Error(`Bad network id: "${network as string}"; expected "testnet", "custom" or "sandbox"`); } } @@ -220,6 +222,32 @@ export abstract class AccountManager implements NearAccountManager { } } +export class CustomnetManager extends AccountManager { + get DEFAULT_INITIAL_BALANCE(): string { + return NEAR.parse('10 N').toJSON(); + } + + get defaultKeyStore(): KeyStore { + return new nearAPI.keyStores.InMemoryKeyStore(); + } + + get connection(): nearAPI.Connection { + return new nearAPI.Connection(this.networkId, this.provider, this.signer, `jsvm.${this.networkId}`); + } + + get networkId(): string { + return this.config.network; + } + + async init(): Promise { + return this; + } + + async createFrom(config: Config): Promise { + return new CustomnetManager(config); + } +} + export class TestnetManager extends AccountManager { static readonly KEYSTORE_PATH: string = path.join(process.cwd(), '.near-credentials', 'workspaces'); private static numTestAccounts = 0; diff --git a/packages/js/src/types.ts b/packages/js/src/types.ts index 213c4232..eb6e93e3 100644 --- a/packages/js/src/types.ts +++ b/packages/js/src/types.ts @@ -55,13 +55,14 @@ export interface AccountBalance { available: NEAR; } -export type Network = 'testnet' | 'mainnet' | 'sandbox'; +export type Network = 'testnet' | 'mainnet' | 'sandbox' | 'custom'; export interface ClientConfig { network: Network; rootAccountId?: string; testnetMasterAccountId?: string; rpcAddr: string; + apiKey?: string; helperUrl?: string; explorerUrl?: string; initialBalance?: string; diff --git a/packages/js/src/utils.ts b/packages/js/src/utils.ts index 3dd5a7d3..0949c251 100644 --- a/packages/js/src/utils.ts +++ b/packages/js/src/utils.ts @@ -56,7 +56,7 @@ export function isTopLevelAccount(accountId: string): boolean { return !accountId.includes('.'); } -function configFromDomain(network: 'testnet' | 'mainnet'): ClientConfig { +function configFromDomain(network: 'testnet' | 'mainnet' | 'custom'): ClientConfig { let rpcAddr = `https://archival-rpc.${network}.near.org`; if (network === 'mainnet' && process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL) { rpcAddr = process.env.NEAR_CLI_MAINNET_RPC_SERVER_URL; @@ -74,8 +74,9 @@ function configFromDomain(network: 'testnet' | 'mainnet'): ClientConfig { }; } -export function urlConfigFromNetwork(network: string | {network: string}): ClientConfig { +export function urlConfigFromNetwork(network: string | {network: string; rpcAddr?: string}): ClientConfig { const networkName = typeof network === 'string' ? network : network.network; + const rpcAddr = typeof network === 'string' ? undefined : network.rpcAddr; switch (networkName) { case 'sandbox': return { @@ -83,10 +84,16 @@ export function urlConfigFromNetwork(network: string | {network: string}): Clien rpcAddr: 'http://localhost', }; + case 'custom': + return { + network: 'custom', + rpcAddr: rpcAddr!, + }; + case 'testnet': case 'mainnet': return configFromDomain(networkName); default: - throw new Error(`Got network ${networkName}, but only accept 'sandbox', 'testnet', and 'mainnet'`); + throw new Error(`Got network ${networkName}, but only accept 'sandbox', 'testnet', 'mainnet' and 'custom'`); } } @@ -107,18 +114,19 @@ export const EMPTY_CONTRACT_HASH = '11111111111111111111111111111111'; * * @returns network to connect to. Default 'sandbox' */ -export function getNetworkFromEnv(): 'sandbox' | 'testnet' { +export function getNetworkFromEnv(): 'sandbox' | 'testnet' | 'custom' { const network = process.env.NEAR_WORKSPACES_NETWORK; switch (network) { case 'sandbox': case 'testnet': + case 'custom': return network; case undefined: return 'sandbox'; default: throw new Error( `environment variable NEAR_WORKSPACES_NETWORK=${network} invalid; ` - + 'use \'testnet\', or \'sandbox\' (the default)', + + 'use \'testnet\', \'custom\', or \'sandbox\' (the default)', ); } } diff --git a/packages/js/src/worker.ts b/packages/js/src/worker.ts index f971c79c..579cffd6 100644 --- a/packages/js/src/worker.ts +++ b/packages/js/src/worker.ts @@ -8,6 +8,8 @@ import {JsonRpcProvider} from './jsonrpc'; import {debug} from './internal-utils'; import {SandboxServer} from './server/server'; +const API_KEY_HEADER = 'x-api-key'; + /** * The main interface to near-workspaces. Create a new worker instance with {@link Worker.init}, then run code on it. */ @@ -43,10 +45,12 @@ export abstract class Worker { return TestnetWorker.init(config); case 'sandbox': return SandboxWorker.init(config); + case 'custom': + return CustomnetWorker.init(config); default: throw new Error( `config.network = '${config.network}' invalid; ` // eslint-disable-line @typescript-eslint/restrict-template-expressions - + 'must be \'testnet\' or \'sandbox\' (the default). Soon \'mainnet\'', + + 'must be \'testnet\', \'sandbox\' or \'custom\' (the default). Soon \'mainnet\'', ); } } @@ -60,11 +64,65 @@ export abstract class Worker { abstract tearDown(): Promise; } +// Connect to a custom network. +// Note: the burden of ensuring the methods that are able to be called are left up to the user. +export class CustomnetWorker extends Worker { + private readonly clientConfig: ClientConfig = urlConfigFromNetwork({network: 'custom', rpcAddr: this.config.rpcAddr}); + + static async init(config: Partial): Promise { + debug('Lifecycle.CustomnetWorker.create()', 'config:', config); + const fullConfig = { + homeDir: 'ignored', + port: 3030, + rm: false, + refDir: null, + ...urlConfigFromNetwork({network: 'custom', rpcAddr: config.rpcAddr}), // Copied over, can't access member clientConfig here + ...config, + }; + + const worker = new CustomnetWorker(fullConfig); + if (config.apiKey) { + worker.provider.connection.headers = { + ...worker.provider.connection.headers, [API_KEY_HEADER]: config.apiKey, + }; + } + + await worker.manager.init(); + return worker; + } + + get provider(): JsonRpcProvider { + return JsonRpcProvider.from(this.clientConfig); + } + + async tearDown(): Promise { + // We are not stopping any server here because it is an external network. + return Promise.resolve(); + } + + get defaultConfig(): Config { + return { + homeDir: 'ignored', + port: 3030, + rm: false, + refDir: null, + ...this.clientConfig, + }; + } +} + export class TestnetWorker extends Worker { static async init(config: Partial): Promise { debug('Lifecycle.TestnetWorker.create()', 'config:', config); const fullConfig = {...this.defaultConfig, ...config}; + const worker = new TestnetWorker(fullConfig); + if (config.apiKey) { + worker.provider.connection.headers = { + ...worker.provider.connection.headers, [API_KEY_HEADER]: config.apiKey, + }; + } + await worker.manager.init(); return worker; } @@ -120,6 +178,12 @@ export class SandboxWorker extends Worker { const release = await lock(syncFilename, retryOptions); const defaultConfig = await this.defaultConfig(); const worker = new SandboxWorker({...defaultConfig, ...config}); + if (config.apiKey) { + worker.provider.connection.headers = { + ...worker.provider.connection.headers, [API_KEY_HEADER]: config.apiKey, + }; + } + worker.server = await SandboxServer.init(worker.config); await worker.server.start(); // Release file lock after near node start