Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public send(data: any, callback: (err, data) => any) {
const { url, ...options } = {
url: 'http://localhost:8545',
...this._options,
};
return fetchJson(url, {
...options,
method: 'POST',
body: JSON.stringify(data),
headers: {'Content-Type': 'application/json' },
}).then((res) => {
return res;
}).then((res) => {
return callback(null, res);
}).catch((err) => {
return callback(err, null);
});
}
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);
}
public send(data: any, callback: (err, data) => any) {
const { url, ...options } = {
url: 'http://localhost:8545',
...this._options,
};
return fetchJson(url, {
...options,
method: 'POST',
body: JSON.stringify(data),
headers: {'Content-Type': 'application/json' },
}).then((res) => {
return res;
}).then((res) => {
return callback(null, res);
}).catch((err) => {
return callback(err, null);
});
}
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);
}