@mintbase-js/sdk
Advanced tools
Comparing version 0.0.4-alpha.1 to 0.0.4-alpha-remove-wallets.0
export declare const GAS = "200000000000000"; | ||
export declare const MAX_GAS = "300000000000000"; | ||
export declare const ONE_YOCTO = "1"; | ||
export declare const TOKEN_CONTRACT_SPEC = "nft-1.0.0"; | ||
export declare const CONTRACT_DEPOSIT = "6500000000000000000000000"; | ||
export declare const TOKEN_METHOD_NAMES: { | ||
@@ -35,2 +37,7 @@ TRANSFER: string; | ||
}; | ||
export declare const MINTBASE_API_KEY_HEADER = "mb-api-key"; | ||
export declare const MINTBASE_API_ANON_USER = "anon"; | ||
export declare const MINTBASE_API_KEY: string; | ||
export declare const ANON_USER_WARNING = "Warning: you are using the anonymous mintbase api key. You may want to specify yours."; | ||
export declare const HOST_BASED_NETWORK_DEFAULT: () => string; | ||
export declare const NEAR_NETWORK: string; | ||
@@ -37,0 +44,0 @@ export declare const MB_MAINNET_TOKEN_FACTORY_ADDRESS = "mintbase1.near"; |
"use strict"; | ||
var _a; | ||
var _a, _b; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DEFAULT_MB_LOGO = exports.MB_TOKEN_FACTORY_ADDRESS = exports.MB_TESTNET_TOKEN_FACTORY_ADDRESS = exports.MB_MAINNET_TOKEN_FACTORY_ADDRESS = exports.NEAR_NETWORK = exports.Network = exports.DEPOSIT_CONSTANTS = exports.GAS_CONSTANTS = exports.MARKET_METHOD_NAMES = exports.TOKEN_METHOD_NAMES = exports.ONE_YOCTO = exports.MAX_GAS = exports.GAS = void 0; | ||
exports.DEFAULT_MB_LOGO = exports.MB_TOKEN_FACTORY_ADDRESS = exports.MB_TESTNET_TOKEN_FACTORY_ADDRESS = exports.MB_MAINNET_TOKEN_FACTORY_ADDRESS = exports.NEAR_NETWORK = exports.HOST_BASED_NETWORK_DEFAULT = exports.ANON_USER_WARNING = exports.MINTBASE_API_KEY = exports.MINTBASE_API_ANON_USER = exports.MINTBASE_API_KEY_HEADER = exports.Network = exports.DEPOSIT_CONSTANTS = exports.GAS_CONSTANTS = exports.MARKET_METHOD_NAMES = exports.TOKEN_METHOD_NAMES = exports.CONTRACT_DEPOSIT = exports.TOKEN_CONTRACT_SPEC = exports.ONE_YOCTO = exports.MAX_GAS = exports.GAS = void 0; | ||
exports.GAS = '200000000000000'; | ||
exports.MAX_GAS = '300000000000000'; | ||
exports.ONE_YOCTO = '1'; | ||
exports.TOKEN_CONTRACT_SPEC = 'nft-1.0.0'; | ||
exports.CONTRACT_DEPOSIT = '6500000000000000000000000'; | ||
exports.TOKEN_METHOD_NAMES = { | ||
@@ -39,3 +41,18 @@ TRANSFER: 'nft_transfer', | ||
}; | ||
exports.NEAR_NETWORK = process.env.NEAR_NETWORK || ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.localStorage) === null || _a === void 0 ? void 0 : _a.getItem('NEAR_NETWORK')) || exports.Network.MAINNET; | ||
exports.MINTBASE_API_KEY_HEADER = 'mb-api-key'; | ||
exports.MINTBASE_API_ANON_USER = 'anon'; | ||
exports.MINTBASE_API_KEY = process.env.MINTBASE_API_KEY || | ||
((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.localStorage) === null || _a === void 0 ? void 0 : _a.getItem('MINTBASE_API_KEY')) || | ||
exports.MINTBASE_API_ANON_USER; | ||
exports.ANON_USER_WARNING = 'Warning: you are using the anonymous mintbase api key. You may want to specify yours.'; | ||
const HOST_BASED_NETWORK_DEFAULT = () => { | ||
var _a; | ||
return ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.window) === null || _a === void 0 ? void 0 : _a.location.host.includes('testnet')) | ||
? exports.Network.TESTNET | ||
: exports.Network.MAINNET; | ||
}; | ||
exports.HOST_BASED_NETWORK_DEFAULT = HOST_BASED_NETWORK_DEFAULT; | ||
exports.NEAR_NETWORK = process.env.NEAR_NETWORK || | ||
((_b = globalThis === null || globalThis === void 0 ? void 0 : globalThis.localStorage) === null || _b === void 0 ? void 0 : _b.getItem('NEAR_NETWORK')) || | ||
(0, exports.HOST_BASED_NETWORK_DEFAULT)(); | ||
exports.MB_MAINNET_TOKEN_FACTORY_ADDRESS = 'mintbase1.near'; | ||
@@ -42,0 +59,0 @@ exports.MB_TESTNET_TOKEN_FACTORY_ADDRESS = 'mintspace2.testnet'; |
export * from './execute'; | ||
export * from './constants'; | ||
export * from './burn/burn'; | ||
export * from './addMinter/addMinter'; | ||
export * from './removeMinter/removeMinter'; | ||
export * from './transfer/transfer'; | ||
export * from './batchChangeMinters/batchChangeMinters'; | ||
export * from './revoke/revoke'; | ||
export * from './deployContract/deployContract'; | ||
export * from './transferContractOwnership/transferContractOwnership'; | ||
export * from './v1/token'; | ||
@@ -6,0 +12,0 @@ export * from './v1/token.types'; |
@@ -21,3 +21,9 @@ "use strict"; | ||
__exportStar(require("./burn/burn"), exports); | ||
__exportStar(require("./addMinter/addMinter"), exports); | ||
__exportStar(require("./removeMinter/removeMinter"), exports); | ||
__exportStar(require("./transfer/transfer"), exports); | ||
__exportStar(require("./batchChangeMinters/batchChangeMinters"), exports); | ||
__exportStar(require("./revoke/revoke"), exports); | ||
__exportStar(require("./deployContract/deployContract"), exports); | ||
__exportStar(require("./transferContractOwnership/transferContractOwnership"), exports); | ||
__exportStar(require("./v1/token"), exports); | ||
@@ -24,0 +30,0 @@ __exportStar(require("./v1/token.types"), exports); |
import { TransactionArgs, TransactionAttachments } from '../execute'; | ||
import { DeployTokenContractArgs, TransferTokenContractOwnership, MintArgs, AddRemoveMinterArgs, BatchChangeMinters, RevokeAccountArgs } from './token.types'; | ||
export declare const deployContract: (args: DeployTokenContractArgs) => TransactionArgs & TransactionAttachments; | ||
export declare const transferContractOwnership: (args: TransferTokenContractOwnership) => TransactionArgs & TransactionAttachments; | ||
import { MintArgs } from './token.types'; | ||
export declare const mint: (args: MintArgs) => TransactionArgs & TransactionAttachments; | ||
export declare const mintMore: () => void; | ||
export declare const addMinter: (args: AddRemoveMinterArgs) => TransactionArgs & TransactionAttachments; | ||
export declare const removeMinter: (args: AddRemoveMinterArgs) => TransactionArgs & TransactionAttachments; | ||
export declare const batchChangeMinters: (args: BatchChangeMinters) => TransactionArgs & TransactionAttachments; | ||
export declare const revoke: (args: RevokeAccountArgs) => TransactionArgs & TransactionAttachments; |
"use strict"; | ||
// Mintbase token contract JS implementation | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.revoke = exports.batchChangeMinters = exports.removeMinter = exports.addMinter = exports.mintMore = exports.mint = exports.transferContractOwnership = exports.deployContract = void 0; | ||
exports.mintMore = exports.mint = void 0; | ||
const constants_1 = require("../constants"); | ||
const deployContract = (args) => { | ||
const { name, factoryContractId = constants_1.Network.TESTNET, ownerId, metadata } = args; | ||
const { symbol, icon, baseUri, reference, referenceHash } = metadata; | ||
const data = { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
owner_id: ownerId, | ||
metadata: { | ||
spec: 'nft-1.0.0', | ||
name: name.replace(/[^a-z0-9]+/gim, '').toLowerCase(), | ||
symbol: symbol.replace(/[^a-z0-9]+/gim, '').toLowerCase(), | ||
icon: icon !== null && icon !== void 0 ? icon : constants_1.DEFAULT_MB_LOGO, | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
base_uri: baseUri !== null && baseUri !== void 0 ? baseUri : null, | ||
reference: reference !== null && reference !== void 0 ? reference : null, | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
reference_hash: referenceHash !== null && referenceHash !== void 0 ? referenceHash : null, | ||
}, | ||
}; | ||
return { | ||
contractAddress: factoryContractId || constants_1.MB_TOKEN_FACTORY_ADDRESS, | ||
methodName: constants_1.TOKEN_METHOD_NAMES.DEPLOY_TOKEN_CONTRACT, | ||
args: data, | ||
gas: constants_1.GAS_CONSTANTS.DEFAULT_GAS, | ||
deposit: '6500000000000000000000000', | ||
}; | ||
}; | ||
exports.deployContract = deployContract; | ||
const transferContractOwnership = (args) => { | ||
const { nftContractId, nextOwner, options } = args; | ||
const { keepMinters = true } = options; | ||
return { | ||
contractAddress: nftContractId, | ||
args: { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
new_owner: nextOwner, | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
keep_old_minters: keepMinters, | ||
}, | ||
methodName: constants_1.TOKEN_METHOD_NAMES.TRANSFER_TOKEN_CONTRACT_OWNERSHIP, | ||
gas: constants_1.GAS_CONSTANTS.DEFAULT_GAS, | ||
deposit: constants_1.DEPOSIT_CONSTANTS.ONE_YOCTO, | ||
}; | ||
}; | ||
exports.transferContractOwnership = transferContractOwnership; | ||
const mint = (args) => { | ||
@@ -66,74 +22,2 @@ const { nftContractId } = args; | ||
exports.mintMore = mintMore; | ||
const addMinter = (args) => { | ||
const { minterId, nftContractId } = args; | ||
return { | ||
contractAddress: nftContractId, | ||
args: { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
account_id: minterId, | ||
}, | ||
methodName: constants_1.TOKEN_METHOD_NAMES.ADD_MINTER, | ||
gas: constants_1.GAS_CONSTANTS.DEFAULT_GAS, | ||
deposit: constants_1.DEPOSIT_CONSTANTS.ONE_YOCTO, | ||
}; | ||
}; | ||
exports.addMinter = addMinter; | ||
const removeMinter = (args) => { | ||
const { minterId, nftContractId } = args; | ||
return { | ||
contractAddress: nftContractId, | ||
args: { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
account_id: minterId, | ||
}, | ||
methodName: constants_1.TOKEN_METHOD_NAMES.REMOVE_MINTER, | ||
gas: constants_1.GAS_CONSTANTS.DEFAULT_GAS, | ||
deposit: constants_1.DEPOSIT_CONSTANTS.ONE_YOCTO, | ||
}; | ||
}; | ||
exports.removeMinter = removeMinter; | ||
const batchChangeMinters = (args) => { | ||
const { addMinters, removeMinters, nftContractId } = args; | ||
return { | ||
contractAddress: nftContractId, | ||
args: { | ||
grant: addMinters.length > 0 ? addMinters : undefined, | ||
revoke: removeMinters.length > 0 ? removeMinters : undefined, | ||
}, | ||
methodName: constants_1.TOKEN_METHOD_NAMES.BATCH_CHANGE_MINTERS, | ||
gas: constants_1.GAS_CONSTANTS.DEFAULT_GAS, | ||
deposit: constants_1.DEPOSIT_CONSTANTS.ONE_YOCTO, | ||
}; | ||
}; | ||
exports.batchChangeMinters = batchChangeMinters; | ||
const revoke = (args) => { | ||
const { nftContractId, tokenId, accountToRevokeId } = args; | ||
if (accountToRevokeId) { | ||
return { | ||
contractAddress: nftContractId, | ||
args: { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
token_id: tokenId, | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
account_id: accountToRevokeId, | ||
}, | ||
methodName: constants_1.TOKEN_METHOD_NAMES.TOKEN_ACCOUNT_REVOKE, | ||
gas: constants_1.GAS_CONSTANTS.DEFAULT_GAS, | ||
deposit: constants_1.DEPOSIT_CONSTANTS.ONE_YOCTO, | ||
}; | ||
} | ||
else { | ||
return { | ||
contractAddress: nftContractId, | ||
args: { | ||
// eslint-disable-next-line @typescript-eslint/camelcase | ||
token_id: tokenId, | ||
}, | ||
methodName: constants_1.TOKEN_METHOD_NAMES.TOKEN_ACCOUNT_REVOKE_ALL, | ||
gas: constants_1.GAS_CONSTANTS.DEFAULT_GAS, | ||
deposit: constants_1.DEPOSIT_CONSTANTS.ONE_YOCTO, | ||
}; | ||
} | ||
}; | ||
exports.revoke = revoke; | ||
//# sourceMappingURL=token.js.map |
@@ -6,21 +6,2 @@ export declare type AccountId = string; | ||
}; | ||
export declare type DeployTokenContractArgs = TokenArgs & { | ||
name: string; | ||
factoryContractId?: AccountId; | ||
ownerId: AccountId; | ||
metadata: { | ||
symbol: string; | ||
icon?: string; | ||
baseUri?: string; | ||
reference?: string; | ||
referenceHash?: string; | ||
}; | ||
}; | ||
export declare type TransferTokenContractOwnership = TokenArgs & { | ||
nftContractId: AccountId; | ||
nextOwner: AccountId; | ||
options?: { | ||
keepMinters: boolean; | ||
}; | ||
}; | ||
export declare type Splits = Record<AccountId, number>; | ||
@@ -42,11 +23,2 @@ export declare type MintArgs = TokenArgs & { | ||
}; | ||
export declare type AddRemoveMinterArgs = TokenArgs & { | ||
minterId: AccountId; | ||
nftContractId: AccountId; | ||
}; | ||
export declare type BatchChangeMinters = TokenArgs & { | ||
addMinters: AccountId[]; | ||
removeMinters: AccountId[]; | ||
nftContractId: AccountId; | ||
}; | ||
export declare type RevokeAccountArgs = TokenArgs & { | ||
@@ -53,0 +25,0 @@ nftContractId: AccountId; |
{ | ||
"name": "@mintbase-js/sdk", | ||
"version": "0.0.4-alpha.1", | ||
"version": "0.0.4-alpha-remove-wallets.0", | ||
"description": "Core functions for Mintbase JS SDK", | ||
@@ -25,3 +25,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "5d553cef73e0808c833301e25a389c2039b4bbc6" | ||
"gitHead": "323d1174828400b19f2e2549c1c10a87e36f5253" | ||
} |
@@ -110,4 +110,4 @@ [//]: # `{ "title": "@mintbase-js/sdk", "order": 0 }` | ||
Should you encounter this [known issue](ttps://docs.near.org/tools/near-api-js/faq#class-x-is-missing-in-schema-publickey) make sure you are not importing modules directly from `near-api-js`, import them from `@mintbase-js/sdk` instead to avoid the duplicate import. | ||
Should you encounter this [known issue](https://docs.near.org/tools/near-api-js/faq#class-x-is-missing-in-schema-publickey) `Class PublicKey is missing in schema: publicKey` make sure you are not importing modules directly from `near-api-js`, import them from `@mintbase-js/sdk` instead to avoid the duplicate import. | ||
{% endhint %} |
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
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
54117
51
783
306