Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let functionSignature = '0x8b1d8335'; // perform
if (order.takerId === zeroAddress) {
functionSignature = '0x04aa2cb7'; // performAnyTaker
}
const recipeTuple = createRecipeTuple(gateway, order);
const signatureTuple = createSignatureTuple(claim);
const attrs = {
from: gateway.provider.accountId,
to: gateway.id,
data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple, signatureTuple]).substr(2),
};
const res = await gateway.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(gateway.provider, res.result);
}
export default async function(provider: GenericProvider, { name, symbol, decimals, supply }: ValueLedgerDeployRecipe) {
const contract = await fetchJson(provider.valueLedgerSource);
const source = contract.TokenMock.evm.bytecode.object;
const attrs = {
from: provider.accountId,
data: `0x${source}${provider.encoder.encodeParameters(inputTypes, [ name, symbol, decimals, supply]).substr(2)}`,
};
const res = await provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(provider, res.result);
}
export default async function(provider: GenericProvider, { name, symbol, uriPrefix, uriPostfix, schemaId, capabilities }: AssetLedgerDeployRecipe) {
const contract = await fetchJson(provider.assetLedgerSource);
const source = contract.XcertMock.evm.bytecode.object;
const codes = (capabilities || []).map((c) => getInterfaceCode(c));
const attrs = {
from: provider.accountId,
data: `0x${source}${provider.encoder.encodeParameters(inputTypes, [name, symbol, uriPrefix, uriPostfix, schemaId, codes]).substr(2)}`,
};
const res = await provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(provider, res.result);
}
export default async function(ledger: AssetLedger, accountId: string, assetId: string) {
const attrs = {
from: ledger.provider.accountId,
to: ledger.id,
data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, assetId]).substr(2),
};
const res = await ledger.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(ledger.provider, res.result, ledger);
}
export default async function(gateway: Gateway, order: AssetLedgerDeployOrder) {
const recipeTuple = createRecipeTuple(order);
const attrs = {
from: gateway.provider.accountId,
to: gateway.config.assetLedgerDeployOrderId,
data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
};
const res = await gateway.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(gateway.provider, res.result, gateway);
}
export default async function(ledger: ValueLedger, accountId: string, value: string) {
const attrs = {
from: ledger.provider.accountId,
to: ledger.id,
data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, value]).substr(2),
};
const res = await ledger.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(ledger.provider, res.result, ledger);
}
export default async function(ledger: AssetLedger, assetId: string) {
const attrs = {
from: ledger.provider.accountId,
to: ledger.id,
data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId]).substr(2),
};
const res = await ledger.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(ledger.provider, res.result, ledger);
}
export default async function(ledger: AssetLedger, accountId: string, abilities: string) {
const attrs = {
from: ledger.provider.accountId,
to: ledger.id,
data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, abilities]).substr(2),
};
const res = await ledger.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(ledger.provider, res.result, ledger);
}
const inputTypes = ['address', 'address', 'uint256'];
if (typeof receiverData !== 'undefined') {
inputTypes.push('bytes');
}
const data = [senderId, receiverId, id, receiverData]
.filter((a) => typeof a !== 'undefined');
const attrs = {
from: ledger.provider.accountId,
to: ledger.id,
data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, data).substr(2),
};
const res = await ledger.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(ledger.provider, res.result, ledger);
}
export default async function(gateway: Gateway, order: ValueLedgerDeployOrder) {
const recipeTuple = createRecipeTuple(order);
const attrs = {
from: gateway.provider.accountId,
to: gateway.config.valueLedgerDeployOrderId,
data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
};
const res = await gateway.provider.post({
method: 'eth_sendTransaction',
params: [attrs],
});
return new Mutation(gateway.provider, res.result, gateway);
}