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/tupelo-client@0.4.0/lib/tupelo.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/tupelo-client@0.4.0/lib/tupelo.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var cbor = require(\"cbor\");\n\nvar messages = require(\"tupelo-messages\");\nvar transactions = messages.transactions;\nvar services = messages.services;\nvar rpcclient = messages.rpcclient;\nvar grpc = messages.grpc;\n\nconst CHAINTREE_DATA_PATH = \"/tree/data\";\n\nconst decodeResolveResponse = (resp) => {\n  var obj = resp.toObject();\n  obj.data = resp.getData_asU8();\n\n  return obj;\n};\n\nconst promiseAroundRpcCallback = (toExec) => {\n  return new Promise((resolve, reject) => {\n    var clbk = (err, response) => {\n      if (err == null) {\n        resolve(response.toObject());\n      } else {\n        reject(err);\n      }\n    };\n    toExec(clbk);\n  });\n};\n\nconst walletCredentials = (credObj) => {\n  var creds = new services.Credentials();\n  creds.setWalletName(credObj.walletName);\n  creds.setPassPhrase(credObj.passPhrase);\n\n  return creds;\n};\n\nconst setOwnershipPayload = (newOwnerKeys) => {\n  var payload = new transactions.SetOwnershipPayload();\n  payload.setAuthenticationList(newOwnerKeys);\n\n  return payload;\n};\n\nconst setOwnershipTransaction = (newOwnerKeys) => {\n  var payload = setOwnershipPayload(newOwnerKeys);\n  var txn = new transactions.Transaction();\n  txn.setType(transactions.Transaction.Type.SETOWNERSHIP);\n  txn.setSetOwnershipPayload(payload);\n\n  return txn;\n};\n\nconst setDataPayload = (path, value) => {\n  var cborData = cbor.Encoder.encode(value);\n\n  var payload = new transactions.SetDataPayload();\n  payload.setPath(path);\n  payload.setValue(cborData);\n\n  return payload;\n};\n\nconst setDataTransaction = (path, value) => {\n  var payload = setDataPayload(path, value);\n  var txn = new transactions.Transaction();\n  txn.setType(transactions.Transaction.Type.SETDATA);\n  txn.setSetDataPayload(payload);\n\n  return txn;\n};\n\nconst establishTokenPayload = (name, maximum) => {\n  var policy = new transactions.TokenMonetaryPolicy();\n  policy.setMaximum(maximum);\n\n  var payload = new transactions.EstablishTokenPayload();\n  payload.setName(name);\n  payload.setMonetaryPolicy(policy);\n\n  return payload;\n};\n\nconst establishTokenTransaction = (name, maximum) => {\n  var payload = establishTokenPayload(name, maximum);\n\n  var txn = new transactions.Transaction();\n  txn.setType(transactions.Transaction.Type.ESTABLISHTOKEN);\n  txn.setEstablishTokenPayload(payload);\n\n  return txn;\n};\n\nconst mintTokenPayload = (name, amount) => {\n  var payload = new transactions.MintTokenPayload();\n  payload.setName(name);\n  payload.setAmount(amount);\n\n  return payload;\n};\n\nconst mintTokenTransaction = (name, amount) => {\n  var payload = mintTokenPayload(name, amount);\n\n  var txn = new transactions.Transaction();\n  txn.setType(transactions.Transaction.Type.MINTTOKEN);\n  txn.setMintTokenPayload(payload);\n\n  return txn;\n};\n\nconst sendTokenPayload = (sendId, name, amount, destinationChainId) => {\n  var payload = new transactions.SendTokenPayload();\n  payload.setId(sendId);\n  payload.setName(name);\n  payload.setAmount(amount);\n  payload.setDestination(destinationChainId);\n\n  return payload;\n};\n\nconst sendTokenTransaction = (sendId, name, amount, destinationChainId) => {\n  var payload = sendTokenPayload(sendId, name, amount, destinationChainId);\n\n  var txn = new transactions.Transaction();\n  txn.setType(transactions.Transaction.Type.SENDTOKEN);\n  txn.setSendTokenPayload(payload);\n\n  return txn;\n};\n\nconst receiveTokenPayload = (sendId, tip, signature, leaves) => {\n  var payload = new transactions.ReceiveTokenPayload();\n  payload.setSendTokenTransactionId(sendId);\n  payload.setTip(tip);\n  payload.setSignature(signature);\n  payload.setLeaves(leaves);\n\n  return payload;\n};\n\nconst receiveTokenTransaction = (sendId, tip, signature, leaves) => {\n  var payload = receiveTokenPayload(sendId, tip, signature, leaves);\n\n  var txn = new transactions.Transaction();\n  txn.setType(transactions.Transaction.Type.RECEIVETOKEN);\n  txn.setReceiveTokenPayload(payload);\n\n  return txn;\n};\n\n/**\n * Connect to a Tupelo wallet managed by a remote Tupelo RPC server.\n *\n * @param {string} walletServer - \"host:port\" string of the RPC wallet server\n * @param {Object} walletCreds - Credentials for the connecting wallet\n * @param {string} walletCreds.walletName - Wallet name\n * @param {string} walletCreds.passPhrase - Wallet passphrase\n *\n * @return {TupeloClient} Tupelo client connection.\n */\nconst connect = (walletServer, walletCreds) => {\n  return new TupeloClient(walletServer, walletCreds);\n};\n\n/**\n * Represents a connection to a specific Tupelo wallet managed by a remote\n * Tupelo RPC server\n */\nclass TupeloClient {\n  constructor(walletServer, walletCreds) {\n    /**\n     * The URL (\"host:port\") of the RPC wallet server to connect to\n     *\n     * @type {string}\n     */\n    this.walletServer = walletServer;\n\n    /**\n     * The name and passphrase of the wallet to connect to\n     *\n     * @type {WalletCredentials}\n     */\n    this.walletCreds = walletCredentials(walletCreds);\n    /**\n     * @typedef {Object} WalletCredentials\n     * @property {string} walletName - Wallet name\n     * @property {string} passPhrase - Wallet passphrase\n     */\n\n\n    /**\n     * Back end Tupelo Wallet RPC service connection\n     *\n     * @type {WalletRPCService}\n     */\n    this.rpc = new rpcclient\n      .WalletRPCServiceClient(walletServer, grpc.credentials.createInsecure());\n  }\n\n  /**\n   * Register a new wallet with the client credentials.\n   *\n   * @return {Promise<RegisterResponse, RpcError>}\n   */\n  register() {\n    return promiseAroundRpcCallback((clbk) => {\n      var req = new services.RegisterWalletRequest();\n      req.setCreds(this.walletCreds);\n\n      this.rpc.register(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} RegisterResponse\n   * @property {string} walletName - The name of the newly registered wallet\n   */\n\n  /**\n   * Generate a new chain tree ownership key pair.\n   *\n   * @return {Promise<GenerateKeyResponse, RpcError>}\n   */\n  generateKey() {\n    return promiseAroundRpcCallback((clbk) => {\n      var req = new services.GenerateKeyRequest();\n      req.setCreds(this.walletCreds);\n\n      this.rpc.generateKey(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} GenerateKeyResponse\n   * @property {string} keyAddr - Public key address\n   */\n\n\n  /**\n   * List the addresses of the keys associated with the connected wallet.\n   *\n   * @return {Promise<ListKeysResponse, RpcError>}\n   */\n  listKeys() {\n    return promiseAroundRpcCallback((clbk) => {\n      var req = new services.ListKeysRequest();\n      req.setCreds(this.walletCreds);\n\n      this.rpc.listKeys(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} ListKeysResponse\n   * @property {string[]} keyAddrs - Public key addresses associated with the connected wallet.\n   */\n\n\n  /**\n   * Create a new chain tree owned by the key at `keyAddr`.\n   *\n   * @param {string} keyAddr - Address of the key that owns the new chain tree.\n   * @param {StorageAdapterConfig} [storageAdapter] - Storage configuration for the chain tree\n   * @return {Promise<CreateChainResponse, RpcError>}\n   */\n  createChainTree(keyAddr, storageAdapter) {\n    return promiseAroundRpcCallback((clbk) => {\n      var req = new services.GenerateChainRequest();\n      req.setCreds(this.walletCreds);\n      req.setKeyAddr(keyAddr);\n      req.setStorageAdapter(storageAdapter);\n\n      this.rpc.createChainTree(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} CreateChainResponse\n   * @property {string} chainId - The ID of the new chain tree\n   */\n\n  /**\n   * Get a Base58 serialized chain tree Export\n   *\n   * @param {string} chainId - The ID of the chain tree to be exported\n   *\n   * @return {Promise<ExportChainTreeResponse, RpcError>}\n   */\n  exportChainTree(chainId) {\n    var req = new services.ExportChainRequest();\n    req.setCreds(this.walletCreds);\n    req.setChainId(chainId);\n\n    return promiseAroundRpcCallback((clbk) => {\n      this.rpc.exportChainTree(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} ExportChainTreeResponse\n   * @property {SerializedChainTree} chainTree - The serialized chain tree\n   */\n\n\n  /**\n   * Import a serialized chain tree and save it to the wallet.\n   *\n   * @param {SerializedChaintree} chainTree - Serialized chain tree to import\n   * @param {StorageAdapterConfig} [storageAdapter] - Storage configuration for the chain tree\n   *\n   *\n   * StorageAdapterConfig\n   */\n  importChainTree(chainTree, storageAdapter) {\n    var req = new services.ImportChainRequest();\n    req.setCreds(this.walletCreds);\n    req.setChainTree(chainTree);\n\n    return promiseAroundRpcCallback((clbk) => {\n      this.rpc.importChainTree(req, clbk);\n    });\n  }\n\n  /**\n   * List the IDs of the chain trees associated with the connected wallet.\n   *\n   * @return {Promise<ListChainIdsResponse, RpcError>}\n   */\n  listChainIds() {\n    var req = new services.ListChainIdsRequest();\n    req.setCreds(this.walletCreds);\n\n    return promiseAroundRpcCallback((clbk) => {\n      this.rpc.listChainIds(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} ListChainIdsResponse\n   * @property {string[]} chainIds - Chain tree IDs associated with this wallet.\n   */\n\n\n  /**\n   * Get the latest tip (as known by the Tupelo network signers) of the chain\n   * tree with id `chainId`\n   *\n   * @param {string} chainId - The ID of the chain tree.\n   *\n   * @return {Promise<GetTipResponse, RpcError>}\n   */\n  getTip(chainId) {\n    var req = new services.GetTipRequest();\n    req.setCreds(this.walletCreds);\n    req.setChainId(chainId);\n\n    return promiseAroundRpcCallback((clbk) => {\n      this.rpc.getTip(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} GetTipResponse\n   * @property {string} tip - The chain tree tip as known by the Tupelo signers\n   */\n\n\n  /**\n   * Apply a sequence of transactions to a chain tree\n   *\n   * @param {string} chainId - The ID of the chain tree to store the data on.\n   * @param {string} keyAddr - Address of the key that owns the chain tree.\n   * @param {Object[]} transactions - List of transactions to apply\n   *\n   * @return {Promise<PlayTransactionsResponse, RpcError>}\n   */\n  playTransactions(chainId, keyAddr, transactions) {\n    var req = new services.PlayTransactionsRequest();\n    req.setCreds(this.walletCreds);\n    req.setChainId(chainId);\n    req.setKeyAddr(keyAddr);\n    req.setTransactionsList(transactions);\n\n    return promiseAroundRpcCallback((clbk) => {\n      this.rpc.playTransactions(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} PlayTransactionsResponse\n   * @property {string} tip - The chain tree tip as known by the Tupelo signers after the transactions are applied\n   */\n\n  /**\n   * Store data on a chain tree with a transaction validated by the network's\n   * notary group.\n   *\n   * @param {string} chainId - The ID of the chain tree to store the data on.\n   * @param {string} keyAddr - Address of the key that owns the chain tree.\n   * @param {string} path - '/' delimited path into the chain tree to store the data\n   * @param {string|number|boolean|Array|Object} value - The data to store.\n   *\n   * @return {Promise<SetDataResponse, RpcError>}\n   */\n  setData(chainId, keyAddr, path, value) {\n    var transaction = setDataTransaction(path, value);\n\n    return this.playTransactions(chainId, keyAddr, [transaction]);\n  }\n  /**\n   * @typedef {Object} SetDataResponse\n   * @property {string} tip - The chain tree tip after the transaction.\n   */\n\n  /**\n   * Resolve data from the root of the chain tree.\n   *\n   * The data will be resolved in the tree according to the path until we reach the end\n   * of the path or a leaf node. If we reach a leaf node before the end of the path,\n   * the data at the leaf node is returned and the remaining unresolved part of the path is\n   * set as the response's `remainingPath` property.\n   * @param {string} chainId - The ID of the chain tree to retrieve the data from.\n   * @param {string} path - '/' delimited path into the chain tree where the data is stored.\n   *\n   * @return {Promise<ResolveResponse, RpcError>}\n   */\n  resolve(chainId, path) {\n    return new Promise((resolve, reject) => {\n      var clbk = (err, response) => {\n        if (err == null) {\n          var responseObj = decodeResolveResponse(response);\n\n          cbor.Decoder.decodeAll(responseObj.data)\n            .then((decoded) => {\n              responseObj.data = decoded;\n              if (responseObj.remainingPath == null) {\n                responseObj.remainingPath = '';\n              }\n              resolve(responseObj);\n            },(err) => {\n              reject(err);\n            });\n        } else {\n          reject(err);\n        }\n      };\n\n      var req = new services.ResolveRequest();\n      req.setCreds(this.walletCreds);\n      req.setChainId(chainId);\n      req.setPath(path);\n\n      this.rpc.resolve(req, clbk);\n    });\n  }\n  /**\n   * @typedef {Object} ResolveResponse\n   * @property {string} remainingPath - The path remaining after retrieving the data\n   * @property {Object} data - The data retrieved\n   */\n\n  /**\n   * Resolve data from the user portion (\"/tree/data\") of the chain tree.\n   *\n   * The data will be resolved in the tree according to the path until we reach the end\n   * of the path or a leaf node. If we reach a leaf node before the end of the path,\n   * the data at the leaf node is returned and the remaining unresolved part of the path is\n   * set as the response's `remainingPath` property.\n   * @param {string} chainId - The ID of the chain tree to retrieve the data from.\n   * @param {string} path - '/' delimited path inside of tree/data where the data is stored.\n   *\n   * @return {Promise<ResolveResponse, RpcError>}\n   */\n  resolveData(chainId, path) {\n    let resolvePath = CHAINTREE_DATA_PATH;\n    let trimmedPath = path ? path.replace(/^\\/+/g, '') : path;\n\n    if (trimmedPath) {\n      resolvePath += \"/\" + trimmedPath;\n    }\n\n    return this.resolve(chainId, resolvePath);\n  }\n\n  /**\n   * Resolve data from a tip of a chain tree given a certain path.\n   *\n   * @param {string} chainId - The ID of the chain tree to retrieve the data from.\n   * @param {string} path - '/' delimited path into the chain tree where the data is stored\n   * @param {string} tip - The tip in question.\n   *\n   * @return {Promise<ResolveResponse, RpcError>}\n   */\n  async resolveAt(chainId, path, tip) {\n    const response = await new Promise((resolve, reject) => {\n      var req = new services.ResolveAtRequest();\n      req.setCreds(this.walletCreds);\n      req.setChainId(chainId);\n      req.setPath(path);\n      req.setTip(tip);\n\n      this.rpc.resolveAt(req, (err, response) => {\n        if (err == null) {\n          resolve(decodeResolveResponse(response));\n        } else {\n          reject(err);\n        }\n      });\n    });\n\n    const decoded = await cbor.Decoder.decodeAll(response.data);\n    response.data = decoded;\n    return response;\n  }\n\n  /**\n   * Define the set of owners of the chain tree with ID `chainId` as the set of keys in\n   * `newOwnerKeys` in a transaction, and register that transaction with the notary group.\n   *\n   * @param {string} chainId - The ID of the chain tree.\n   * @param {string} keyAddr - Address of a key that currently owns the chain tree.\n   * @param {string[]} newOwnerKeys - List of key addresses for the new owners.\n   *\n   * @return {Promise<SetOwnerResponse, RpcError>}\n   */\n  setOwner(chainId, keyAddr, newOwnerKeys) {\n    var transaction = setOwnershipTransaction(newOwnerKeys);\n\n    return this.playTransactions(chainId, keyAddr, [transaction]);\n  }\n  /**\n   * @typedef {Object} SetOwnerResponse\n   * @property {string} tip - The chain tree tip after the transaction.\n   */\n\n  /**\n   * Establish a new token type associated with a chain tree.\n   *\n   * @param {string} chainId - The ID of the chain tree.\n   * @param {string} keyAddr - Address of a key that currently owns the chain tree.\n   * @param {string} tokenName - Name of the new token\n   * @param {number} maximum - Maximum number of tokens of this type that can exist\n   *\n   * @return {Promise<EstablishTokenResponse, RpcError>}\n   */\n  establishToken(chainId, keyAddr, tokenName, maximum) {\n    var transaction = establishTokenTransaction(tokenName, maximum);\n\n    return this.playTransactions(chainId, keyAddr, [transaction]);\n  }\n  /**\n   * @typedef {Object} EstablishTokenResponse\n   * @property {string} tip - The chain tree tip after the transaction.\n   */\n\n  /**\n   * Mint new tokens of an already established token type associated with a chain\n   * tree.\n   *\n   * @param {string} chainId - The ID of the chain tree.\n   * @param {string} keyAddr - Address of a key that currently owns the chain tree.\n   * @param {string} tokenName - Name of the token type\n   * @param {number} amount - Number of tokens to mint.\n   *\n   * @return {Promise<MintTokenResponse, RpcError>}\n   */\n  mintToken(chainId, keyAddr, tokenName, amount) {\n    var transaction = mintTokenTransaction(tokenName, amount);\n\n    return this.playTransactions(chainId, keyAddr, [transaction]);\n  }\n  /**\n   * @typedef {Object} MintTokenResponse\n   * @property {string} tip - The chain tree tip after the transaction.\n   */\n\n  /**\n   * Send an amount of minted tokens to another chain tree.\n   *\n   * @param {string} chainId - The ID of the sending chain tree.\n   * @param {string} keyAddr - Address of a key that currently owns the chain tree.\n   * @param {string} tokenName - Name of the token type.\n   * @param {string} destinationChainId - The ID of the recipient chain tree.\n   * @param {number} amount - Number of tokens to send.\n   */\n   sendToken(chainId, keyAddr, tokenName, destinationChainId, amount) {\n     return promiseAroundRpcCallback((clbk) => {\n       var req = new services.SendTokenRequest();\n       req.setCreds(this.walletCreds);\n       req.setChainId(chainId);\n       req.setKeyAddr(keyAddr);\n       req.setTokenName(tokenName);\n       req.setDestinationChainId(destinationChainId);\n       req.setAmount(amount);\n\n       this.rpc.sendToken(req, clbk);\n     });\n   }\n\n   /**\n   * Receive a send token payload from another chain tree.\n   *\n   * @param {string} chainId - The ID of the sending chain tree.\n   * @param {string} keyAddr - Address of a key that currently owns the chain tree.\n   * @param {string} tokenPayload - The base64-encoded token send payload.\n   */\n   receiveToken(chainId, keyAddr, tokenPayload) {\n     return promiseAroundRpcCallback((clbk) => {\n       var req = new services.ReceiveTokenRequest();\n       req.setCreds(this.walletCreds);\n       req.setChainId(chainId);\n       req.setKeyAddr(keyAddr);\n       req.setTokenPayload(tokenPayload);\n\n       this.rpc.receiveToken(req, clbk);\n     });\n   }\n\n  /**\n   * @typedef {Object} StorageAdapterConfigForBadger\n   * @property {string} path - Path for badger db\n   */\n\n  /**\n   * @typedef {Object} StorageAdapterConfigForIpld\n   * @property {string} [path] - Path to ipld initialized configuration. Either path or address is required.\n   * @property {string} [address] - Multiaddr for ipfs http api. Either path or address is required.\n   * @property {boolean} [online=false] - if true, starts IPFS node in online mode\n   */\n\n  /**\n   * @typedef {Object} StorageAdapterConfig\n   * @property {StorageAdapterConfigForBadger} badger - Configure and use the badger storage adapter\n   * @property {StorageAdapterConfigForIpld} ipld - Configure and use the ipld storage adapter\n   */\n\n  /**\n   * @typedef {Object} SerializedChainTree\n   * @property {string} tip - Hash of the latest root tree node.\n   * @property {string[]} dag - base58 encoded string array representing the chain tree dag nodes\n   * @property {Map<String, SerializedSignature>} signatures - Map of serialized signatures\n   */\n\n  /**\n   * @typedef {Object} SerializedSignature\n   * @property {boolean[]} signers - Array indicating which signers have signed\n   * @property {string} signature - base58 encoded signature\n   * @property {string} type - Signature type\n   */\n\n  /**\n   * @typedef {Object} RpcError - gRPC error object\n   * @property {number} code - A [gRPC status](https://grpc.io/grpc/node/grpc.html#.status)\n   * @property {string} details - Details about the error\n   * @property {?Object} metadata - Additional information about the error\n   */\n}\n\nexports.setOwnershipPayload = setOwnershipPayload;\nexports.setOwnershipTransaction = setOwnershipTransaction;\nexports.setDataPayload = setDataPayload;\nexports.setDataTransaction = setDataTransaction;\nexports.establishTokenPayload = establishTokenPayload;\nexports.establishTokenTransaction = establishTokenTransaction;\nexports.mintTokenPayload = mintTokenPayload;\nexports.mintTokenTransaction = mintTokenTransaction;\nexports.connect = connect;\nexports.TupeloClient = TupeloClient;\n"]}