Skip to content

Instantly share code, notes, and snippets.

@nautical
Created July 22, 2019 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nautical/8f86dd3309af3849d7117b6e7fc562f0 to your computer and use it in GitHub Desktop.
Save nautical/8f86dd3309af3849d7117b6e7fc562f0 to your computer and use it in GitHub Desktop.
const headers = {
headers: {
"content-type": "application/json"
}
};
const accel = {
createWallet: async (endPoint, auth) => {
try {
const makeCreateWalletRequest = await axios.post(
`${endPoint}/createWallet?auth=${auth}`
);
return makeCreateWalletRequest.data;
} catch (error) {
throw error;
}
},
getBalance: async (endPoint, auth, wallet) => {
try {
const params = {
params: {
wallet
}
};
const makeCallRequest = await axios.get(
`${endPoint}/getBalance?auth=${auth}`,
params
);
return makeCallRequest.data;
} catch (error) {
throw error;
}
},
sendTransaction: async (
endPoint,
auth,
walletFrom,
walletTo,
amount,
gas = null,
unit = "wei",
delegate = false
) => {
try {
const params = {
from: walletFrom,
to: walletTo,
amount,
gas,
unit,
delegate
};
const makeCallRequest = await axios.post(
`${endPoint}/send?auth=${auth}`,
params,
headers
);
return makeCallRequest.data;
} catch (error) {
throw error;
}
},
call: async (endPoint, auth, id, method, args = []) => {
try {
const params = {
id,
method,
args: JSON.stringify(args)
};
const makeCallRequest = await axios.post(
`${endPoint}/call?auth=${auth}`,
params,
headers
);
return makeCallRequest.data;
} catch (error) {
throw error;
}
},
transaction: async (
endPoint,
auth,
id,
method,
args = [],
wallet,
gas = null,
delegate = false
) => {
try {
const params = {
id,
method,
args: JSON.stringify(args),
wallet,
gas,
delegate
};
const makeCallRequest = await axios.post(
`${endPoint}/transaction?auth=${auth}`,
params,
headers
);
return makeCallRequest.data;
} catch (error) {
throw error;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment