@scallop-io/sui-kit
Advanced tools
Comparing version 0.33.1 to 0.34.0
@@ -36,4 +36,4 @@ "use strict"; | ||
__export(src_exports, { | ||
SUI_CLOCK_OBJECT_ID: () => import_sui8.SUI_CLOCK_OBJECT_ID, | ||
SUI_SYSTEM_STATE_OBJECT_ID: () => import_sui8.SUI_SYSTEM_STATE_OBJECT_ID, | ||
SUI_CLOCK_OBJECT_ID: () => import_sui9.SUI_CLOCK_OBJECT_ID, | ||
SUI_SYSTEM_STATE_OBJECT_ID: () => import_sui9.SUI_SYSTEM_STATE_OBJECT_ID, | ||
SuiAccountManager: () => SuiAccountManager, | ||
@@ -43,9 +43,9 @@ SuiKit: () => SuiKit, | ||
SuiTxBlock: () => SuiTxBlock, | ||
TransactionBlock: () => import_sui8.TransactionBlock | ||
TransactionBlock: () => import_sui9.TransactionBlock | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var import_sui8 = require("@mysten/sui.js"); | ||
var import_sui9 = require("@mysten/sui.js"); | ||
// src/lib/sui-kit.ts | ||
var import_sui7 = require("@mysten/sui.js"); | ||
var import_sui8 = require("@mysten/sui.js"); | ||
@@ -165,3 +165,3 @@ // src/lib/sui-account-manager/sui-account-manager.ts | ||
// src/lib/sui-rpc-provider/sui-rpc-provider.ts | ||
var import_sui5 = require("@mysten/sui.js"); | ||
var import_sui6 = require("@mysten/sui.js"); | ||
@@ -206,32 +206,15 @@ // src/lib/sui-rpc-provider/faucet.ts | ||
// src/lib/sui-rpc-provider/default-chain-configs.ts | ||
var DEFAULT_LOCALHOST_FULLNODE = "http://0.0.0.0:9000"; | ||
var DEFAULT_LOCALHOST_FAUCET = ""; | ||
var DEFAULT_DEVNET_FULLNODE = "https://fullnode.devnet.sui.io:443"; | ||
var DEFAULT_DEVNET_FAUCET = "https://faucet.devnet.sui.io/gas"; | ||
var DEFAULT_TESTNET_FULLNODE = "https://fullnode.testnet.sui.io:443"; | ||
var DEFAULT_TESTNET_FAUCET = "https://faucet.testnet.sui.io/gas"; | ||
var DEFAULT_MAINNET_FULLNODE = "https://fullnode.mainnet.sui.io:443"; | ||
var DEFAULT_MAINNET_FAUCET = ""; | ||
var import_sui5 = require("@mysten/sui.js"); | ||
var getDefaultNetworkParams = (networkType = "devnet") => { | ||
switch (networkType) { | ||
case "localhost": | ||
return { | ||
fullNode: DEFAULT_LOCALHOST_FULLNODE, | ||
faucet: DEFAULT_LOCALHOST_FAUCET | ||
}; | ||
case "localnet": | ||
return import_sui5.localnetConnection; | ||
case "devnet": | ||
return import_sui5.devnetConnection; | ||
case "testnet": | ||
return { | ||
fullNode: DEFAULT_TESTNET_FULLNODE, | ||
faucet: DEFAULT_TESTNET_FAUCET | ||
}; | ||
return import_sui5.testnetConnection; | ||
case "mainnet": | ||
return { | ||
fullNode: DEFAULT_MAINNET_FULLNODE, | ||
faucet: DEFAULT_MAINNET_FAUCET | ||
}; | ||
return import_sui5.mainnetConnection; | ||
default: | ||
return { | ||
fullNode: DEFAULT_DEVNET_FULLNODE, | ||
faucet: DEFAULT_DEVNET_FAUCET | ||
}; | ||
return import_sui5.devnetConnection; | ||
} | ||
@@ -244,3 +227,3 @@ }; | ||
* | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type | ||
@@ -251,9 +234,9 @@ * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type | ||
const defaultNetworkParams = getDefaultNetworkParams(networkType || "devnet"); | ||
this.fullnodeUrl = fullnodeUrl || defaultNetworkParams.fullNode; | ||
this.fullnodeUrl = fullnodeUrl || defaultNetworkParams.fullnode; | ||
this.faucetUrl = faucetUrl || defaultNetworkParams.faucet; | ||
const connection = new import_sui5.Connection({ | ||
const connection = new import_sui6.Connection({ | ||
fullnode: this.fullnodeUrl, | ||
faucet: this.faucetUrl | ||
}); | ||
this.provider = new import_sui5.JsonRpcProvider(connection); | ||
this.provider = new import_sui6.JsonRpcProvider(connection); | ||
} | ||
@@ -274,7 +257,7 @@ /** | ||
const parsedObjects = objects.map((object) => { | ||
const objectId = (0, import_sui5.getObjectId)(object); | ||
const objectType = (0, import_sui5.getObjectType)(object); | ||
const objectVersion = (0, import_sui5.getObjectVersion)(object); | ||
const objectFields = (0, import_sui5.getObjectFields)(object); | ||
const objectDisplay = (0, import_sui5.getObjectDisplay)(object); | ||
const objectId = (0, import_sui6.getObjectId)(object); | ||
const objectType = (0, import_sui6.getObjectType)(object); | ||
const objectVersion = (0, import_sui6.getObjectVersion)(object); | ||
const objectFields = (0, import_sui6.getObjectFields)(object); | ||
const objectDisplay = (0, import_sui6.getObjectDisplay)(object); | ||
return { objectId, objectType, objectVersion, objectFields, objectDisplay }; | ||
@@ -314,3 +297,3 @@ }); | ||
// src/lib/sui-tx-builder/sui-tx-block.ts | ||
var import_sui6 = require("@mysten/sui.js"); | ||
var import_sui7 = require("@mysten/sui.js"); | ||
@@ -336,3 +319,3 @@ // src/lib/sui-tx-builder/util.ts | ||
__privateAdd(this, _convertArgs); | ||
this.txBlock = new import_sui6.TransactionBlock(); | ||
this.txBlock = new import_sui7.TransactionBlock(); | ||
} | ||
@@ -426,3 +409,3 @@ transferSuiToMany(recipients, amounts) { | ||
target: "0x3::sui_system::request_add_stake", | ||
arguments: [tx.object(import_sui6.SUI_SYSTEM_STATE_OBJECT_ID), stakeCoin, tx.pure(validatorAddr)] | ||
arguments: [tx.object(import_sui7.SUI_SYSTEM_STATE_OBJECT_ID), stakeCoin, tx.pure(validatorAddr)] | ||
}); | ||
@@ -460,3 +443,3 @@ return tx; | ||
const objects = args.map( | ||
(arg) => typeof arg === "string" ? this.txBlock.object((0, import_sui6.normalizeSuiObjectId)(arg)) : arg | ||
(arg) => typeof arg === "string" ? this.txBlock.object((0, import_sui7.normalizeSuiObjectId)(arg)) : arg | ||
); | ||
@@ -480,3 +463,3 @@ return this.txBlock.makeMoveVec({ objects }); | ||
if (typeof arg === "string" && arg.startsWith("0x")) { | ||
return this.txBlock.object((0, import_sui6.normalizeSuiObjectId)(arg)); | ||
return this.txBlock.object((0, import_sui7.normalizeSuiObjectId)(arg)); | ||
} else if (__privateMethod(this, _isMoveVecArg, isMoveVecArg_fn).call(this, arg)) { | ||
@@ -503,3 +486,3 @@ const vecType = arg.vecType || void 0; | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type | ||
@@ -520,3 +503,3 @@ * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type | ||
const keyPair = this.accountManager.getKeyPair(derivePathParams); | ||
return new import_sui7.RawSigner(keyPair, this.rpcProvider.provider); | ||
return new import_sui8.RawSigner(keyPair, this.rpcProvider.provider); | ||
} | ||
@@ -523,0 +506,0 @@ /** |
@@ -36,4 +36,4 @@ "use strict"; | ||
__export(src_exports, { | ||
SUI_CLOCK_OBJECT_ID: () => import_sui8.SUI_CLOCK_OBJECT_ID, | ||
SUI_SYSTEM_STATE_OBJECT_ID: () => import_sui8.SUI_SYSTEM_STATE_OBJECT_ID, | ||
SUI_CLOCK_OBJECT_ID: () => import_sui9.SUI_CLOCK_OBJECT_ID, | ||
SUI_SYSTEM_STATE_OBJECT_ID: () => import_sui9.SUI_SYSTEM_STATE_OBJECT_ID, | ||
SuiAccountManager: () => SuiAccountManager, | ||
@@ -43,9 +43,9 @@ SuiKit: () => SuiKit, | ||
SuiTxBlock: () => SuiTxBlock, | ||
TransactionBlock: () => import_sui8.TransactionBlock | ||
TransactionBlock: () => import_sui9.TransactionBlock | ||
}); | ||
module.exports = __toCommonJS(src_exports); | ||
var import_sui8 = require("@mysten/sui.js"); | ||
var import_sui9 = require("@mysten/sui.js"); | ||
// src/lib/sui-kit.ts | ||
var import_sui7 = require("@mysten/sui.js"); | ||
var import_sui8 = require("@mysten/sui.js"); | ||
@@ -165,3 +165,3 @@ // src/lib/sui-account-manager/sui-account-manager.ts | ||
// src/lib/sui-rpc-provider/sui-rpc-provider.ts | ||
var import_sui5 = require("@mysten/sui.js"); | ||
var import_sui6 = require("@mysten/sui.js"); | ||
@@ -206,32 +206,15 @@ // src/lib/sui-rpc-provider/faucet.ts | ||
// src/lib/sui-rpc-provider/default-chain-configs.ts | ||
var DEFAULT_LOCALHOST_FULLNODE = "http://0.0.0.0:9000"; | ||
var DEFAULT_LOCALHOST_FAUCET = ""; | ||
var DEFAULT_DEVNET_FULLNODE = "https://fullnode.devnet.sui.io:443"; | ||
var DEFAULT_DEVNET_FAUCET = "https://faucet.devnet.sui.io/gas"; | ||
var DEFAULT_TESTNET_FULLNODE = "https://fullnode.testnet.sui.io:443"; | ||
var DEFAULT_TESTNET_FAUCET = "https://faucet.testnet.sui.io/gas"; | ||
var DEFAULT_MAINNET_FULLNODE = "https://fullnode.mainnet.sui.io:443"; | ||
var DEFAULT_MAINNET_FAUCET = ""; | ||
var import_sui5 = require("@mysten/sui.js"); | ||
var getDefaultNetworkParams = (networkType = "devnet") => { | ||
switch (networkType) { | ||
case "localhost": | ||
return { | ||
fullNode: DEFAULT_LOCALHOST_FULLNODE, | ||
faucet: DEFAULT_LOCALHOST_FAUCET | ||
}; | ||
case "localnet": | ||
return import_sui5.localnetConnection; | ||
case "devnet": | ||
return import_sui5.devnetConnection; | ||
case "testnet": | ||
return { | ||
fullNode: DEFAULT_TESTNET_FULLNODE, | ||
faucet: DEFAULT_TESTNET_FAUCET | ||
}; | ||
return import_sui5.testnetConnection; | ||
case "mainnet": | ||
return { | ||
fullNode: DEFAULT_MAINNET_FULLNODE, | ||
faucet: DEFAULT_MAINNET_FAUCET | ||
}; | ||
return import_sui5.mainnetConnection; | ||
default: | ||
return { | ||
fullNode: DEFAULT_DEVNET_FULLNODE, | ||
faucet: DEFAULT_DEVNET_FAUCET | ||
}; | ||
return import_sui5.devnetConnection; | ||
} | ||
@@ -244,3 +227,3 @@ }; | ||
* | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type | ||
@@ -251,9 +234,9 @@ * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type | ||
const defaultNetworkParams = getDefaultNetworkParams(networkType || "devnet"); | ||
this.fullnodeUrl = fullnodeUrl || defaultNetworkParams.fullNode; | ||
this.fullnodeUrl = fullnodeUrl || defaultNetworkParams.fullnode; | ||
this.faucetUrl = faucetUrl || defaultNetworkParams.faucet; | ||
const connection = new import_sui5.Connection({ | ||
const connection = new import_sui6.Connection({ | ||
fullnode: this.fullnodeUrl, | ||
faucet: this.faucetUrl | ||
}); | ||
this.provider = new import_sui5.JsonRpcProvider(connection); | ||
this.provider = new import_sui6.JsonRpcProvider(connection); | ||
} | ||
@@ -274,7 +257,7 @@ /** | ||
const parsedObjects = objects.map((object) => { | ||
const objectId = (0, import_sui5.getObjectId)(object); | ||
const objectType = (0, import_sui5.getObjectType)(object); | ||
const objectVersion = (0, import_sui5.getObjectVersion)(object); | ||
const objectFields = (0, import_sui5.getObjectFields)(object); | ||
const objectDisplay = (0, import_sui5.getObjectDisplay)(object); | ||
const objectId = (0, import_sui6.getObjectId)(object); | ||
const objectType = (0, import_sui6.getObjectType)(object); | ||
const objectVersion = (0, import_sui6.getObjectVersion)(object); | ||
const objectFields = (0, import_sui6.getObjectFields)(object); | ||
const objectDisplay = (0, import_sui6.getObjectDisplay)(object); | ||
return { objectId, objectType, objectVersion, objectFields, objectDisplay }; | ||
@@ -314,3 +297,3 @@ }); | ||
// src/lib/sui-tx-builder/sui-tx-block.ts | ||
var import_sui6 = require("@mysten/sui.js"); | ||
var import_sui7 = require("@mysten/sui.js"); | ||
@@ -336,3 +319,3 @@ // src/lib/sui-tx-builder/util.ts | ||
__privateAdd(this, _convertArgs); | ||
this.txBlock = new import_sui6.TransactionBlock(); | ||
this.txBlock = new import_sui7.TransactionBlock(); | ||
} | ||
@@ -426,3 +409,3 @@ transferSuiToMany(recipients, amounts) { | ||
target: "0x3::sui_system::request_add_stake", | ||
arguments: [tx.object(import_sui6.SUI_SYSTEM_STATE_OBJECT_ID), stakeCoin, tx.pure(validatorAddr)] | ||
arguments: [tx.object(import_sui7.SUI_SYSTEM_STATE_OBJECT_ID), stakeCoin, tx.pure(validatorAddr)] | ||
}); | ||
@@ -460,3 +443,3 @@ return tx; | ||
const objects = args.map( | ||
(arg) => typeof arg === "string" ? this.txBlock.object((0, import_sui6.normalizeSuiObjectId)(arg)) : arg | ||
(arg) => typeof arg === "string" ? this.txBlock.object((0, import_sui7.normalizeSuiObjectId)(arg)) : arg | ||
); | ||
@@ -480,3 +463,3 @@ return this.txBlock.makeMoveVec({ objects }); | ||
if (typeof arg === "string" && arg.startsWith("0x")) { | ||
return this.txBlock.object((0, import_sui6.normalizeSuiObjectId)(arg)); | ||
return this.txBlock.object((0, import_sui7.normalizeSuiObjectId)(arg)); | ||
} else if (__privateMethod(this, _isMoveVecArg, isMoveVecArg_fn).call(this, arg)) { | ||
@@ -503,3 +486,3 @@ const vecType = arg.vecType || void 0; | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type | ||
@@ -520,3 +503,3 @@ * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type | ||
const keyPair = this.accountManager.getKeyPair(derivePathParams); | ||
return new import_sui7.RawSigner(keyPair, this.rpcProvider.provider); | ||
return new import_sui8.RawSigner(keyPair, this.rpcProvider.provider); | ||
} | ||
@@ -523,0 +506,0 @@ /** |
@@ -0,22 +1,8 @@ | ||
import type { Connection } from '@mysten/sui.js'; | ||
export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet'; | ||
/** | ||
* @description This file is used to store the default chain parameters for the different networks. | ||
* @author IceFox@Scallop | ||
*/ | ||
export declare const DEFAULT_LOCALHOST_FULLNODE = "http://0.0.0.0:9000"; | ||
export declare const DEFAULT_LOCALHOST_FAUCET = ""; | ||
export declare const DEFAULT_DEVNET_FULLNODE = "https://fullnode.devnet.sui.io:443"; | ||
export declare const DEFAULT_DEVNET_FAUCET = "https://faucet.devnet.sui.io/gas"; | ||
export declare const DEFAULT_TESTNET_FULLNODE = "https://fullnode.testnet.sui.io:443"; | ||
export declare const DEFAULT_TESTNET_FAUCET = "https://faucet.testnet.sui.io/gas"; | ||
export declare const DEFAULT_MAINNET_FULLNODE = "https://fullnode.mainnet.sui.io:443"; | ||
export declare const DEFAULT_MAINNET_FAUCET = ""; | ||
export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localhost'; | ||
/** | ||
* @description Get the default fullnode url and faucet url for the given network type | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @returns { fullNode: string, faucet: string } | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @returns { fullNode: string, websocket: string, faucet?: string } | ||
*/ | ||
export declare const getDefaultNetworkParams: (networkType?: NetworkType) => { | ||
fullNode: string; | ||
faucet: string; | ||
}; | ||
export declare const getDefaultNetworkParams: (networkType?: NetworkType) => Connection; |
@@ -17,7 +17,7 @@ import { JsonRpcProvider, DisplayFieldsResponse, ObjectContentFields } from "@mysten/sui.js"; | ||
fullnodeUrl: string; | ||
faucetUrl: string; | ||
faucetUrl?: string; | ||
provider: JsonRpcProvider; | ||
/** | ||
* | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type | ||
@@ -24,0 +24,0 @@ * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type |
{ | ||
"name": "@scallop-io/sui-kit", | ||
"version": "0.33.1", | ||
"version": "0.34.0", | ||
"description": "Tookit for interacting with SUI network", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@mysten/sui.js": "^0.33.0", | ||
"@mysten/sui.js": "^0.34.0", | ||
"@scure/bip39": "^1.2.0", | ||
@@ -50,6 +50,6 @@ "assert": "^2.0.0", | ||
"peerDependencies": { | ||
"@mysten/sui.js": "^0.33.0" | ||
"@mysten/sui.js": "^0.34.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.15.11", | ||
"@types/node": "^20.1.5", | ||
"@types/tmp": "^0.2.3", | ||
@@ -59,3 +59,3 @@ "dotenv": "^16.0.3", | ||
"tsup": "^6.7.0", | ||
"typescript": "^5.0.2" | ||
"typescript": "^5.0.4" | ||
}, | ||
@@ -62,0 +62,0 @@ "scripts": { |
@@ -16,3 +16,3 @@ # Tookit for interacting with SUI network | ||
```bash | ||
npm install @scallop-dao/sui-kit | ||
npm install @scallop-io/sui-kit | ||
``` | ||
@@ -26,3 +26,3 @@ | ||
```typescript | ||
import { SuiKit } from '@scallop-dao/sui-kit'; | ||
import { SuiKit } from '@scallop-io/sui-kit'; | ||
@@ -163,3 +163,3 @@ // The following types of secret key are supported: | ||
```typescript | ||
import { SuiKit, SuiTxBlock } from "@scallop-dao/sui-kit"; | ||
import { SuiKit, SuiTxBlock } from "@scallop-io/sui-kit"; | ||
import * as process from "process"; | ||
@@ -221,3 +221,3 @@ import * as dotenv from "dotenv"; | ||
*/ | ||
import { SuiKit } from '@scallop-dao/sui-kit'; | ||
import { SuiKit } from '@scallop-io/sui-kit'; | ||
@@ -256,3 +256,3 @@ async function checkAccounts(suiKit: SuiKit) { | ||
```bash | ||
npm install @scallop-dao/sui-package-kit | ||
npm install @scallop-io/sui-package-kit | ||
``` | ||
@@ -267,3 +267,3 @@ | ||
*/ | ||
import { SuiKit } from "@scallop-dao/sui-kit"; | ||
import { SuiKit } from "@scallop-io/sui-kit"; | ||
import { SuiPackagePublisher } from "@scallop-dao/sui-package-kit"; | ||
@@ -286,3 +286,3 @@ | ||
*/ | ||
import { SuiKit } from "@scallop-dao/sui-kit"; | ||
import { SuiKit } from "@scallop-io/sui-kit"; | ||
import { SuiPackagePublisher } from "@scallop-dao/sui-package-kit"; | ||
@@ -289,0 +289,0 @@ |
@@ -36,3 +36,3 @@ /** | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type | ||
@@ -39,0 +39,0 @@ * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type |
@@ -1,52 +0,29 @@ | ||
/** | ||
* @description This file is used to store the default chain parameters for the different networks. | ||
* @author IceFox@Scallop | ||
*/ | ||
// For localhost | ||
export const DEFAULT_LOCALHOST_FULLNODE = "http://0.0.0.0:9000" | ||
export const DEFAULT_LOCALHOST_FAUCET = "" | ||
import { | ||
localnetConnection, | ||
devnetConnection, | ||
testnetConnection, | ||
mainnetConnection, | ||
} from '@mysten/sui.js' | ||
import type { Connection } from '@mysten/sui.js' | ||
// For devnet | ||
export const DEFAULT_DEVNET_FULLNODE ="https://fullnode.devnet.sui.io:443" | ||
export const DEFAULT_DEVNET_FAUCET = "https://faucet.devnet.sui.io/gas" | ||
export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localnet'; | ||
// For testnet | ||
export const DEFAULT_TESTNET_FULLNODE = "https://fullnode.testnet.sui.io:443" | ||
export const DEFAULT_TESTNET_FAUCET = "https://faucet.testnet.sui.io/gas" | ||
// For mainnet | ||
export const DEFAULT_MAINNET_FULLNODE = "https://fullnode.mainnet.sui.io:443" | ||
export const DEFAULT_MAINNET_FAUCET = "" | ||
export type NetworkType = 'testnet' | 'mainnet' | 'devnet' | 'localhost'; | ||
/** | ||
* @description Get the default fullnode url and faucet url for the given network type | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @returns { fullNode: string, faucet: string } | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @returns { fullNode: string, websocket: string, faucet?: string } | ||
*/ | ||
export const getDefaultNetworkParams = (networkType: NetworkType = 'devnet'): { fullNode: string, faucet: string } => { | ||
export const getDefaultNetworkParams = (networkType: NetworkType = 'devnet'): Connection => { | ||
switch (networkType) { | ||
case 'localhost': | ||
return { | ||
fullNode: DEFAULT_LOCALHOST_FULLNODE, | ||
faucet: DEFAULT_LOCALHOST_FAUCET, | ||
} | ||
case 'localnet': | ||
return localnetConnection | ||
case 'devnet': | ||
return devnetConnection | ||
case 'testnet': | ||
return { | ||
fullNode: DEFAULT_TESTNET_FULLNODE, | ||
faucet: DEFAULT_TESTNET_FAUCET, | ||
} | ||
return testnetConnection | ||
case 'mainnet': | ||
return { | ||
fullNode: DEFAULT_MAINNET_FULLNODE, | ||
faucet: DEFAULT_MAINNET_FAUCET, | ||
} | ||
return mainnetConnection | ||
default: | ||
return { | ||
fullNode: DEFAULT_DEVNET_FULLNODE, | ||
faucet: DEFAULT_DEVNET_FAUCET, | ||
} | ||
return devnetConnection | ||
} | ||
} |
@@ -31,7 +31,7 @@ import { | ||
public fullnodeUrl: string; | ||
public faucetUrl: string; | ||
public faucetUrl?: string; | ||
public provider: JsonRpcProvider; | ||
/** | ||
* | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localhost', default is 'devnet' | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'devnet' | ||
* @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type | ||
@@ -44,3 +44,3 @@ * @param faucetUrl, the faucet url, default is the preconfig faucet url for the given network type | ||
// Set fullnodeUrl and faucetUrl, if they are not provided, use the default value. | ||
this.fullnodeUrl = fullnodeUrl || defaultNetworkParams.fullNode; | ||
this.fullnodeUrl = fullnodeUrl || defaultNetworkParams.fullnode; | ||
this.faucetUrl = faucetUrl || defaultNetworkParams.faucet; | ||
@@ -47,0 +47,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318849
5556
+ Added@mysten/sui.js@0.34.1(transitive)
- Removed@mysten/sui.js@0.33.0(transitive)
Updated@mysten/sui.js@^0.34.0