Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
number = new BigNumber(id)
} catch (e) {
throw error
}
// Infinity
if (!number.isFinite()) {
throw error
}
// NaN
if (number.isNaN()) {
throw error
}
return xdr.Memo.memoId(UnsignedHyper.fromString(id))
}
ext: new xdr.CreateAccountOpExt(xdr.LedgerVersion.emptyVersion())
}
if (!isUndefined(opts.referrer) && !(opts.referrer === '')) {
console.log(opts.referrer)
if (!Keypair.isValidPublicKey(opts.referrer)) {
throw new TypeError('referrer is invalid')
}
attrs.referrer = Keypair.fromAccountId(opts.referrer).xdrAccountId()
}
if (isUndefined(opts.roleID)) {
throw new Error('roleID is undefined')
}
attrs.roleId = UnsignedHyper.fromString(opts.roleID)
if (isUndefined(opts.signersData)) {
throw new Error('signersData is undefined')
}
if (!isArray(opts.signersData)) {
throw new Error('signersData is not array')
}
if (opts.signersData.length === 0) {
throw new Error('signersData is empty')
}
attrs.signersData = []
for (let signerData of opts.signersData) {
attrs.signersData.push(ManageSignerBuilder.prepareUpdateSignerData(signerData))
static cancelSale (opts) {
if (isUndefined(opts.saleID)) {
throw new Error('opts.saleID is invalid')
}
let manageSaleOp = new xdr.ManageSaleOp({
saleId: UnsignedHyper.fromString(opts.saleID),
data: new xdr.ManageSaleOpData.cancel(),
ext: new xdr.ManageSaleOpExt(xdr.LedgerVersion.emptyVersion())
})
let opAttrs = {}
opAttrs.body = xdr.OperationBody.manageSale(manageSaleOp)
BaseOperation.setSourceAccount(opAttrs, opts)
return new xdr.Operation(opAttrs)
}
})
validateArray({
value: opts.operations,
fieldName: 'opts.operations',
minLength: 1,
maxLength: 100
})
let rrOperations = []
for (let op of opts.operations) {
rrOperations.push(this.convertOperationToReviewableRequestOperation(op))
}
let attributes = {
creatorDetails: JSON.stringify(opts.creatorDetails),
requestId: UnsignedHyper.fromString(opts.requestID),
operations: rrOperations,
ext: new xdr.EmptyExt(xdr.LedgerVersion.emptyVersion())
}
let updateRequest = new xdr.UpdateReviewableRequestOp(attributes)
let opAttributes = {}
opAttributes.body = new xdr.OperationBody.updateReviewableRequest(updateRequest)
BaseOperation.setSourceAccount(opAttributes, opts)
return new xdr.Operation(opAttributes)
}
static _createVote (opts, attrs) {
if (isUndefined(opts.pollID)) {
throw new Error('opts.pollID is undefined')
}
attrs.pollId = UnsignedHyper.fromString(opts.pollID)
attrs.ext = new xdr.CreateVoteDataExt(xdr.LedgerVersion.emptyVersion())
return this._manageVote(opts, new xdr.ManageVoteOpData.create(
new xdr.CreateVoteData(attrs)))
}
}
if (isUndefined(opts.saleID)) {
throw new Error('opts.saleID is invalid')
}
SaleRequestBuilder.validateDetail(opts.newDetails)
let updateSaleDetailsData = new xdr.UpdateSaleDetailsData({
requestId: UnsignedHyper.fromString(opts.requestID),
newDetails: JSON.stringify(opts.newDetails),
ext: new xdr.UpdateSaleDetailsDataExt(xdr.LedgerVersion.emptyVersion())
})
let manageSaleOp = new xdr.ManageSaleOp({
saleId: UnsignedHyper.fromString(opts.saleID),
data: new xdr.ManageSaleOpData.createUpdateDetailsRequest(
updateSaleDetailsData
),
ext: new xdr.ManageSaleOpExt(xdr.LedgerVersion.emptyVersion())
})
let opAttrs = {}
opAttrs.body = xdr.OperationBody.manageSale(manageSaleOp)
BaseOperation.setSourceAccount(opAttrs, opts)
return new xdr.Operation(opAttrs)
}
attrs.saleType = UnsignedHyper.fromString(opts.saleType)
if (!BaseOperation.isValidAsset(opts.defaultQuoteAsset)) {
throw new Error('opts.defaultQuoteAsset is invalid')
}
attrs.defaultQuoteAsset = opts.defaultQuoteAsset
if (isUndefined(opts.startTime)) {
throw new Error('opts.startTime is invalid')
}
attrs.startTime = UnsignedHyper.fromString(opts.startTime)
if (isUndefined(opts.endTime)) {
throw new Error('opts.endTime is invalid')
}
attrs.endTime = UnsignedHyper.fromString(opts.endTime)
if (!BaseOperation.isValidAmount(opts.softCap, true)) {
throw new Error('opts.softCap is invalid')
}
attrs.softCap = BaseOperation._toUnsignedXDRAmount(opts.softCap)
if (!BaseOperation.isValidAmount(opts.hardCap, true)) {
throw new Error('opts.hardCap is invalid')
}
attrs.hardCap = BaseOperation._toUnsignedXDRAmount(opts.hardCap)
SaleRequestBuilder.validateDetail(opts.creatorDetails)
attrs.creatorDetails = JSON.stringify(opts.creatorDetails)
attrs.ext = new xdr.SaleCreationRequestExt(xdr.LedgerVersion.emptyVersion())
if (isUndefined(opts.saleEnumType) || !opts.saleEnumType) {
if (isUndefined(opts.identity)) {
throw new Error('identity of signer is undefined')
}
if (isUndefined(opts.weight)) {
throw new Error('weight of signer is undefined')
}
let weight = Number.parseInt(opts.weight, 10)
if (weight > 1000) {
throw new Error('weight must not be greater than 1000')
}
let attrs = {
publicKey: Keypair.fromAccountId(opts.publicKey).xdrPublicKey(),
roleId: UnsignedHyper.fromString(opts.roleID),
weight: weight,
identity: Number.parseInt(opts.identity, 10),
details: JSON.stringify(opts.details),
ext: new xdr.EmptyExt(xdr.LedgerVersion.emptyVersion())
}
return new xdr.UpdateSignerData(attrs)
}
static validateSaleCreationRequest (opts) {
let attrs = {}
if (!BaseOperation.isValidAsset(opts.baseAsset)) {
throw new Error('opts.baseAsset is invalid')
}
attrs.baseAsset = opts.baseAsset
if (isUndefined(opts.saleType)) {
throw new Error('opts.saleType is undefined')
}
attrs.saleType = UnsignedHyper.fromString(opts.saleType)
if (!BaseOperation.isValidAsset(opts.defaultQuoteAsset)) {
throw new Error('opts.defaultQuoteAsset is invalid')
}
attrs.defaultQuoteAsset = opts.defaultQuoteAsset
if (isUndefined(opts.startTime)) {
throw new Error('opts.startTime is invalid')
}
attrs.startTime = UnsignedHyper.fromString(opts.startTime)
if (isUndefined(opts.endTime)) {
throw new Error('opts.endTime is invalid')
}
attrs.endTime = UnsignedHyper.fromString(opts.endTime)
if (isUndefined(opts.requestID)) {
throw new Error('opts.requestID is invalid')
}
if (!Keypair.isValidPublicKey(opts.destinationAccount)) {
throw new Error('opts.accountToUpdateKYC is invalid')
}
attrs.destinationAccount = Keypair
.fromAccountId(opts.destinationAccount)
.xdrAccountId()
attrs.accountRoleToSet = UnsignedHyper.fromString(opts.accountRoleToSet)
attrs.creatorDetails = JSON.stringify(opts.creatorDetails)
attrs.requestId = UnsignedHyper.fromString(opts.requestID)
attrs.allTasks = BaseOperation._checkUnsignedIntValue('allTasks', opts.allTasks)
attrs.ext = new xdr.CreateChangeRoleRequestOpExt(xdr.LedgerVersion.emptyVersion())
let kycRequestOp = new xdr.CreateChangeRoleRequestOp(attrs)
let opAttributes = {}
opAttributes.body = xdr.OperationBody.createChangeRoleRequest(kycRequestOp)
BaseOperation.setSourceAccount(opAttributes, opts)
return new xdr.Operation(opAttributes)
}