@tableland/sdk
Advanced tools
Comparing version 5.1.0 to 5.1.1
@@ -13,2 +13,8 @@ import { providers, type Signer, type Overrides, type ContractTransaction, type ContractReceipt } from "ethers"; | ||
/** | ||
* Check if a chain is Polygon. | ||
* @param chainId The chainId of the network. | ||
* @returns A boolean that indicates if the chain is a mainnet/testnet Polygon. | ||
*/ | ||
export declare function isPolygon(chainId: number): boolean; | ||
/** | ||
* RegistryReceipt is based on the TransactionReceipt type which defined by the API spec. | ||
@@ -15,0 +21,0 @@ * The API v1 has a known problem where it only returns the first tableId from a transaction. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getDefaultProvider = exports.getSigner = exports.getContractReceipt = exports.getOverrides = void 0; | ||
exports.getDefaultProvider = exports.getSigner = exports.getContractReceipt = exports.isPolygon = exports.getOverrides = void 0; | ||
const ethers_1 = require("ethers"); | ||
@@ -17,3 +17,3 @@ const { getDefaultProvider, Web3Provider } = ethers_1.providers; | ||
/* c8 ignore next 7 */ | ||
if (network?.chainId === 137) { | ||
if (network && isPolygon(network.chainId)) { | ||
const feeData = await signer.getFeeData(); | ||
@@ -29,2 +29,11 @@ if (feeData.gasPrice != null) { | ||
/** | ||
* Check if a chain is Polygon. | ||
* @param chainId The chainId of the network. | ||
* @returns A boolean that indicates if the chain is a mainnet/testnet Polygon. | ||
*/ | ||
function isPolygon(chainId) { | ||
return chainId === 137 || chainId === 80001; | ||
} | ||
exports.isPolygon = isPolygon; | ||
/** | ||
* | ||
@@ -31,0 +40,0 @@ * Given a transaction, this helper will return the tableIds that were part of the transaction. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getController = exports.lockController = exports.setController = void 0; | ||
const ethers_js_1 = require("../helpers/ethers.js"); | ||
const contract_js_1 = require("./contract.js"); | ||
@@ -9,2 +10,7 @@ async function setController({ signer }, params) { | ||
const controller = params.controller; | ||
const chainId = await signer.getChainId(); | ||
if ((0, ethers_js_1.isPolygon)(chainId)) { | ||
const gasLimit = await contract.estimateGas.setController(caller, tableId, controller, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract.setController(caller, tableId, controller, overrides); | ||
@@ -16,2 +22,7 @@ } | ||
const caller = await signer.getAddress(); | ||
const chainId = await signer.getChainId(); | ||
if ((0, ethers_js_1.isPolygon)(chainId)) { | ||
const gasLimit = await contract.estimateGas.lockController(caller, tableId, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract.lockController(caller, tableId, overrides); | ||
@@ -18,0 +29,0 @@ } |
@@ -5,2 +5,3 @@ "use strict"; | ||
const index_js_1 = require("../helpers/index.js"); | ||
const ethers_js_1 = require("../helpers/ethers.js"); | ||
const parser_js_1 = require("../helpers/parser.js"); | ||
@@ -38,2 +39,6 @@ const contract_js_1 = require("./contract.js"); | ||
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId); | ||
if ((0, ethers_js_1.isPolygon)(chainId)) { | ||
const gasLimit = await contract.estimateGas["create(address,string)"](owner, statement, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["create(address,string)"](owner, statement, overrides); | ||
@@ -44,2 +49,6 @@ } | ||
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId); | ||
if ((0, ethers_js_1.isPolygon)(chainId)) { | ||
const gasLimit = await contract.estimateGas["create(address,string[])"](owner, statements, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["create(address,string[])"](owner, statements, overrides); | ||
@@ -46,0 +55,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mutate = exports.prepareMutateOne = void 0; | ||
const ethers_js_1 = require("../helpers/ethers.js"); | ||
const parser_js_1 = require("../helpers/parser.js"); | ||
@@ -22,2 +23,6 @@ const contract_js_1 = require("./contract.js"); | ||
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId); | ||
if ((0, ethers_js_1.isPolygon)(chainId)) { | ||
const gasLimit = await contract.estimateGas["mutate(address,uint256,string)"](caller, tableId, statement, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["mutate(address,uint256,string)"](caller, tableId, statement, overrides); | ||
@@ -28,2 +33,6 @@ } | ||
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId); | ||
if ((0, ethers_js_1.isPolygon)(chainId)) { | ||
const gasLimit = await contract.estimateGas["mutate(address,(uint256,string)[])"](caller, runnables, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["mutate(address,(uint256,string)[])"](caller, runnables, overrides); | ||
@@ -30,0 +39,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.safeTransferFrom = void 0; | ||
const ethers_js_1 = require("../helpers/ethers.js"); | ||
const contract_js_1 = require("./contract.js"); | ||
@@ -8,2 +9,7 @@ async function safeTransferFrom({ signer }, params) { | ||
const caller = await signer.getAddress(); | ||
const chainId = await signer.getChainId(); | ||
if ((0, ethers_js_1.isPolygon)(chainId)) { | ||
const gasLimit = await contract.estimateGas["safeTransferFrom(address,address,uint256)"](caller, params.to, tableId, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["safeTransferFrom(address,address,uint256)"](caller, params.to, tableId, overrides); | ||
@@ -10,0 +16,0 @@ } |
@@ -13,2 +13,8 @@ import { providers, type Signer, type Overrides, type ContractTransaction, type ContractReceipt } from "ethers"; | ||
/** | ||
* Check if a chain is Polygon. | ||
* @param chainId The chainId of the network. | ||
* @returns A boolean that indicates if the chain is a mainnet/testnet Polygon. | ||
*/ | ||
export declare function isPolygon(chainId: number): boolean; | ||
/** | ||
* RegistryReceipt is based on the TransactionReceipt type which defined by the API spec. | ||
@@ -15,0 +21,0 @@ * The API v1 has a known problem where it only returns the first tableId from a transaction. |
@@ -13,3 +13,3 @@ import { providers, } from "ethers"; | ||
/* c8 ignore next 7 */ | ||
if (network?.chainId === 137) { | ||
if (network && isPolygon(network.chainId)) { | ||
const feeData = await signer.getFeeData(); | ||
@@ -24,2 +24,10 @@ if (feeData.gasPrice != null) { | ||
/** | ||
* Check if a chain is Polygon. | ||
* @param chainId The chainId of the network. | ||
* @returns A boolean that indicates if the chain is a mainnet/testnet Polygon. | ||
*/ | ||
export function isPolygon(chainId) { | ||
return chainId === 137 || chainId === 80001; | ||
} | ||
/** | ||
* | ||
@@ -26,0 +34,0 @@ * Given a transaction, this helper will return the tableIds that were part of the transaction. |
@@ -0,1 +1,2 @@ | ||
import { isPolygon } from "../helpers/ethers.js"; | ||
import { getContractSetup } from "./contract.js"; | ||
@@ -6,2 +7,7 @@ export async function setController({ signer }, params) { | ||
const controller = params.controller; | ||
const chainId = await signer.getChainId(); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas.setController(caller, tableId, controller, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract.setController(caller, tableId, controller, overrides); | ||
@@ -12,2 +18,7 @@ } | ||
const caller = await signer.getAddress(); | ||
const chainId = await signer.getChainId(); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas.lockController(caller, tableId, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract.lockController(caller, tableId, overrides); | ||
@@ -14,0 +25,0 @@ } |
import { normalize } from "../helpers/index.js"; | ||
import { isPolygon } from "../helpers/ethers.js"; | ||
import { validateTableName } from "../helpers/parser.js"; | ||
@@ -32,2 +33,6 @@ import { getContractAndOverrides } from "./contract.js"; | ||
const { contract, overrides } = await getContractAndOverrides(signer, chainId); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas["create(address,string)"](owner, statement, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["create(address,string)"](owner, statement, overrides); | ||
@@ -38,2 +43,6 @@ } | ||
const { contract, overrides } = await getContractAndOverrides(signer, chainId); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas["create(address,string[])"](owner, statements, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["create(address,string[])"](owner, statements, overrides); | ||
@@ -40,0 +49,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { isPolygon } from "../helpers/ethers.js"; | ||
import { validateTableName } from "../helpers/parser.js"; | ||
@@ -17,2 +18,6 @@ import { getContractAndOverrides, assertChainId, } from "./contract.js"; | ||
const { contract, overrides } = await getContractAndOverrides(signer, chainId); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas["mutate(address,uint256,string)"](caller, tableId, statement, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["mutate(address,uint256,string)"](caller, tableId, statement, overrides); | ||
@@ -23,2 +28,6 @@ } | ||
const { contract, overrides } = await getContractAndOverrides(signer, chainId); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas["mutate(address,(uint256,string)[])"](caller, runnables, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["mutate(address,(uint256,string)[])"](caller, runnables, overrides); | ||
@@ -25,0 +34,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { isPolygon } from "../helpers/ethers.js"; | ||
import { getContractSetup } from "./contract.js"; | ||
@@ -5,4 +6,9 @@ export async function safeTransferFrom({ signer }, params) { | ||
const caller = await signer.getAddress(); | ||
const chainId = await signer.getChainId(); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas["safeTransferFrom(address,address,uint256)"](caller, params.to, tableId, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["safeTransferFrom(address,address,uint256)"](caller, params.to, tableId, overrides); | ||
} | ||
//# sourceMappingURL=transfer.js.map |
{ | ||
"name": "@tableland/sdk", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "A database client and helpers for the Tableland network", | ||
"repository": "https://github.com/tablelandnetwork/tableland-js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/tablelandnetwork/tableland-js.git", | ||
"directory": "packages/sdk" | ||
}, | ||
"publishConfig": { | ||
@@ -56,7 +60,2 @@ "access": "public" | ||
], | ||
"nx": { | ||
"implicitDependencies": [ | ||
"!@tableland/local" | ||
] | ||
}, | ||
"scripts": { | ||
@@ -85,12 +84,2 @@ "prepublishOnly": "npm run build", | ||
"license": "MIT AND Apache-2.0", | ||
"devDependencies": { | ||
"@databases/escape-identifier": "^1.0.3", | ||
"@databases/sql": "^3.2.0", | ||
"@ethersproject/experimental": "^5.7.0", | ||
"@playwright/test": "^1.30.0", | ||
"d1-orm": "^0.9.0", | ||
"drizzle-orm": "^0.29.0", | ||
"openapi-typescript": "6.2.4", | ||
"typedoc": "^0.25.0" | ||
}, | ||
"dependencies": { | ||
@@ -102,3 +91,3 @@ "@async-generators/from-emitter": "^0.3.0", | ||
}, | ||
"gitHead": "89e0e7385900476a4416672b3d7995a9fc9f4376" | ||
"gitHead": "29a84d67f71e1542f904cbdde40758c2ef96d334" | ||
} |
@@ -32,3 +32,3 @@ import { | ||
/* c8 ignore next 7 */ | ||
if (network?.chainId === 137) { | ||
if (network && isPolygon(network.chainId)) { | ||
const feeData = await signer.getFeeData(); | ||
@@ -44,2 +44,11 @@ if (feeData.gasPrice != null) { | ||
/** | ||
* Check if a chain is Polygon. | ||
* @param chainId The chainId of the network. | ||
* @returns A boolean that indicates if the chain is a mainnet/testnet Polygon. | ||
*/ | ||
export function isPolygon(chainId: number): boolean { | ||
return chainId === 137 || chainId === 80001; | ||
} | ||
/** | ||
* RegistryReceipt is based on the TransactionReceipt type which defined by the API spec. | ||
@@ -46,0 +55,0 @@ * The API v1 has a known problem where it only returns the first tableId from a transaction. |
import { type SignerConfig } from "../helpers/config.js"; | ||
import { type ContractTransaction } from "../helpers/ethers.js"; | ||
import { type ContractTransaction, isPolygon } from "../helpers/ethers.js"; | ||
import { type TableIdentifier, getContractSetup } from "./contract.js"; | ||
@@ -26,2 +26,12 @@ | ||
const controller = params.controller; | ||
const chainId = await signer.getChainId(); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas.setController( | ||
caller, | ||
tableId, | ||
controller, | ||
overrides | ||
); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract.setController(caller, tableId, controller, overrides); | ||
@@ -39,2 +49,11 @@ } | ||
const caller = await signer.getAddress(); | ||
const chainId = await signer.getChainId(); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas.lockController( | ||
caller, | ||
tableId, | ||
overrides | ||
); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract.lockController(caller, tableId, overrides); | ||
@@ -41,0 +60,0 @@ } |
import { normalize } from "../helpers/index.js"; | ||
import { type SignerConfig } from "../helpers/config.js"; | ||
import { type ContractTransaction } from "../helpers/ethers.js"; | ||
import { type ContractTransaction, isPolygon } from "../helpers/ethers.js"; | ||
import { validateTableName } from "../helpers/parser.js"; | ||
@@ -99,2 +99,10 @@ import { getContractAndOverrides } from "./contract.js"; | ||
); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas["create(address,string)"]( | ||
owner, | ||
statement, | ||
overrides | ||
); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["create(address,string)"](owner, statement, overrides); | ||
@@ -112,2 +120,10 @@ } | ||
); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas["create(address,string[])"]( | ||
owner, | ||
statements, | ||
overrides | ||
); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["create(address,string[])"]( | ||
@@ -114,0 +130,0 @@ owner, |
import { type SignerConfig } from "../helpers/config.js"; | ||
import { type ContractTransaction } from "../helpers/ethers.js"; | ||
import { type ContractTransaction, isPolygon } from "../helpers/ethers.js"; | ||
import { validateTableName } from "../helpers/parser.js"; | ||
@@ -87,2 +87,8 @@ import { | ||
); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas[ | ||
"mutate(address,uint256,string)" | ||
](caller, tableId, statement, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["mutate(address,uint256,string)"]( | ||
@@ -105,2 +111,8 @@ caller, | ||
); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas[ | ||
"mutate(address,(uint256,string)[])" | ||
](caller, runnables, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["mutate(address,(uint256,string)[])"]( | ||
@@ -107,0 +119,0 @@ caller, |
import { type SignerConfig } from "../helpers/config.js"; | ||
import { type ContractTransaction } from "../helpers/ethers.js"; | ||
import { type ContractTransaction, isPolygon } from "../helpers/ethers.js"; | ||
import { type TableIdentifier, getContractSetup } from "./contract.js"; | ||
@@ -25,2 +25,9 @@ | ||
const caller = await signer.getAddress(); | ||
const chainId = await signer.getChainId(); | ||
if (isPolygon(chainId)) { | ||
const gasLimit = await contract.estimateGas[ | ||
"safeTransferFrom(address,address,uint256)" | ||
](caller, params.to, tableId, overrides); | ||
overrides.gasLimit = Math.floor(gasLimit.toNumber() * 1.2); | ||
} | ||
return await contract["safeTransferFrom(address,address,uint256)"]( | ||
@@ -27,0 +34,0 @@ caller, |
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 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 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 not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
609797
0
11625
0