Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createSignatureTuple(claim: string[] | string) {
if (typeof claim === 'string') {
const [kind, signature] = claim.split(':');
const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
const signatureData = {
r: signature.substr(0, 66),
s: `0x${signature.substr(66, 64)}`,
v: parseInt(`0x${signature.substr(130, 2)}`),
k,
};
if (signatureData.v < 27) {
signatureData.v = signatureData.v + 27;
}
return toTuple(signatureData);
} else {
const signatures = [];
claim.forEach((c) => {
const [kind, signature] = c.split(':');
const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
const signatureData = {
r: signature.substr(0, 66),
s: `0x${signature.substr(66, 64)}`,
v: parseInt(`0x${signature.substr(130, 2)}`),
k,
};
if (signatureData.v < 27) {
signatureData.v = signatureData.v + 27;
}
signatures.push(signatureData);
export function createSignatureTuple(claim: string) {
const [kind, signature] = claim.split(':');
const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
const signatureData = {
r: signature.substr(0, 66),
s: `0x${signature.substr(66, 64)}`,
v: parseInt(`0x${signature.substr(130, 2)}`),
k,
};
if (signatureData.v < 27) {
signatureData.v = signatureData.v + 27;
}
return toTuple(signatureData);
}
claim.forEach((c) => {
const [kind, signature] = c.split(':');
const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
const signatureData = {
r: signature.substr(0, 66),
s: `0x${signature.substr(66, 64)}`,
v: parseInt(`0x${signature.substr(130, 2)}`),
k,
};
if (signatureData.v < 27) {
signatureData.v = signatureData.v + 27;
}
signatures.push(signatureData);
});
return toTuple(signatures);
}
}
export function createSignatureTuple(claim: string) {
const [kind, signature] = claim.split(':');
const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
const signatureData = {
r: signature.substr(0, 66),
s: `0x${signature.substr(66, 64)}`,
v: parseInt(`0x${signature.substr(130, 2)}`),
k,
};
if (signatureData.v < 27) {
signatureData.v = signatureData.v + 27;
}
return toTuple(signatureData);
}
export function createSignatureTuple(claim: string) {
const [kind, signature] = claim.split(':');
const k = (parseInt(kind) == SignMethod.PERSONAL_SIGN) ? SignMethod.ETH_SIGN : kind;
const signatureData = {
r: signature.substr(0, 66),
s: `0x${signature.substr(66, 64)}`,
v: parseInt(`0x${signature.substr(130, 2)}`),
k,
};
if (signatureData.v < 27) {
signatureData.v = signatureData.v + 27;
}
return toTuple(signatureData);
}
uriPrefix: order.assetLedgerData.uriPrefix,
uriPostfix: order.assetLedgerData.uriPostfix,
schemaId: `0x${order.assetLedgerData.schemaId}`,
capabilities: order.assetLedgerData.capabilities.map((c) => { return getInterfaceCode(c); }),
owner: order.assetLedgerData.ownerId,
},
transferData: {
token: order.tokenTransferData.ledgerId,
to: order.tokenTransferData.receiverId,
value: getValue(order.tokenTransferData.value),
},
seed: toInteger(order.seed),
expirationTimestamp: toSeconds(order.expiration),
};
return toTuple(recipeData);
}
name: order.valueLedgerData.name,
symbol: order.valueLedgerData.symbol,
supply: order.valueLedgerData.supply,
decimals: order.valueLedgerData.decimals,
owner: order.valueLedgerData.ownerId,
},
transferData: {
token: order.tokenTransferData.ledgerId,
to: order.tokenTransferData.receiverId,
value: getValue(order.tokenTransferData.value),
},
seed: toInteger(order.seed),
expirationTimestamp: toSeconds(order.expiration),
};
return toTuple(recipeData);
}
export function createRecipeTuple(gateway: Gateway, order: ActionsOrder) {
const actions = (order.actions as ActionsOrderAction[]).map((action) => {
return {
proxyId: getActionProxy(gateway, action),
contractAddress: action.ledgerId,
params: getActionParams(action, order.signers),
};
});
const recipeData = {
signers: order.signers,
actions,
seed: toInteger(order.seed),
expirationTimestamp: toSeconds(order.expiration),
};
return toTuple(recipeData);
}
symbol: deploy.assetLedgerData.symbol,
uriBase: deploy.assetLedgerData.uriBase,
schemaId: deploy.assetLedgerData.schemaId,
capabilities: deploy.assetLedgerData.capabilities.map((c) => { return getInterfaceCode(c); }),
owner: deploy.assetLedgerData.owner,
},
transferData: {
token: deploy.tokenTransferData.ledgerId,
to: deploy.tokenTransferData.receiverId,
value: getValue(deploy.tokenTransferData.value),
},
seed: toInteger(deploy.seed),
expirationTimestamp: toSeconds(deploy.expiration),
};
return toTuple(recipeData);
}