UNPKG

xrpl

Version:

A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser

173 lines 6.29 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const src_1 = require("../../src"); const client = new src_1.Client('wss://s.devnet.rippletest.net:51233'); function permDEXExamples() { return __awaiter(this, void 0, void 0, function* () { yield client.connect(); const { wallet: wallet1 } = yield client.fundWallet(null, { usageContext: 'code snippets', }); const { wallet: wallet2 } = yield client.fundWallet(null, { usageContext: 'code snippets', }); const { wallet: issuerWallet } = yield client.fundWallet(null, { usageContext: 'code snippets', }); yield client.submitAndWait({ TransactionType: 'AccountSet', Account: issuerWallet.classicAddress, SetFlag: src_1.AccountSetAsfFlags.asfDefaultRipple, }, { wallet: issuerWallet, }); yield client.submitAndWait({ TransactionType: 'CredentialCreate', Subject: wallet1.classicAddress, Account: issuerWallet.classicAddress, CredentialType: 'ABCD', }, { wallet: issuerWallet, }); yield client.submitAndWait({ TransactionType: 'CredentialCreate', Subject: wallet2.classicAddress, Account: issuerWallet.classicAddress, CredentialType: 'ABCD', }, { wallet: issuerWallet, }); yield client.submitAndWait({ TransactionType: 'CredentialAccept', Account: wallet1.classicAddress, Issuer: issuerWallet.classicAddress, CredentialType: 'ABCD', }, { wallet: wallet1, }); yield client.submitAndWait({ TransactionType: 'CredentialAccept', Account: wallet2.classicAddress, Issuer: issuerWallet.classicAddress, CredentialType: 'ABCD', }, { wallet: wallet2, }); yield client.submitAndWait({ TransactionType: 'PermissionedDomainSet', Account: issuerWallet.classicAddress, AcceptedCredentials: [ { Credential: { CredentialType: 'ABCD', Issuer: issuerWallet.classicAddress, }, }, ], }, { wallet: issuerWallet, }); const result = yield client.request({ command: 'account_objects', account: issuerWallet.classicAddress, type: 'permissioned_domain', }); const pd_ledger_object = result.result.account_objects[0]; yield client.submitAndWait({ TransactionType: 'Payment', Account: wallet1.classicAddress, Amount: '10000', Destination: wallet2.classicAddress, DomainID: pd_ledger_object.index, }, { wallet: wallet1, }); yield client.submitAndWait({ TransactionType: 'TrustSet', Account: wallet1.classicAddress, LimitAmount: { currency: 'USD', issuer: issuerWallet.classicAddress, value: '10000', }, }, { wallet: wallet1, }); yield client.submitAndWait({ TransactionType: 'TrustSet', Account: wallet2.classicAddress, LimitAmount: { currency: 'USD', issuer: issuerWallet.classicAddress, value: '10000', }, }, { wallet: wallet2, }); yield client.submitAndWait({ TransactionType: 'Payment', Account: issuerWallet.classicAddress, Amount: { currency: 'USD', issuer: issuerWallet.classicAddress, value: '1000', }, Destination: wallet1.classicAddress, }, { wallet: issuerWallet, }); yield client.submitAndWait({ TransactionType: 'Payment', Account: issuerWallet.classicAddress, Amount: { currency: 'USD', issuer: issuerWallet.classicAddress, value: '1000', }, Destination: wallet2.classicAddress, }, { wallet: issuerWallet, }); yield client.submitAndWait({ TransactionType: 'OfferCreate', Account: wallet1.classicAddress, TakerGets: '10', TakerPays: { currency: 'USD', issuer: issuerWallet.classicAddress, value: '10', }, Flags: src_1.OfferCreateFlags.tfHybrid, DomainID: pd_ledger_object.index, }, { wallet: wallet1, }); const offerTxResponse2 = yield client.submitAndWait({ TransactionType: 'OfferCreate', Account: wallet2.classicAddress, TakerPays: '10', TakerGets: { currency: 'USD', issuer: issuerWallet.classicAddress, value: '10', }, Flags: src_1.OfferCreateFlags.tfHybrid, DomainID: pd_ledger_object.index, }, { wallet: wallet2, }); console.log('offerTxResponse2: ', offerTxResponse2); yield client.disconnect(); }); } void permDEXExamples(); //# sourceMappingURL=permissionedDEX.js.map