-
-
Notifications
You must be signed in to change notification settings - Fork 11
API Specification
Нужно описать
метод https://github.com/Adamant-im/adamant-api-jsclient/blob/master/groups/get.js
To collect information from ADAMANT blockchain you need to use get.js
module.
api.get(type, input)
type
—
input
—
Type variants:
Type | Url | returned_field |
---|---|---|
account |
/api/accounts?address= |
- |
[full_account ][full_account] |
https://explorer.adamant.im/api/getAccount?address= |
- |
[delegate_forged ][delegate_forged] |
/api/delegates/forging/getForgedByAccount?generatorPublicKey= |
- |
[account_delegates ][account_delegates] |
/api/accounts/delegates?address= |
delegates |
[block ][block] |
/api/blocks/get?id= |
- |
[blocks ][blocks] |
/api/blocks |
blocks |
[state ][state] |
/api/states/get?id= |
- |
[delegate ][delegate] |
/api/delegates/get?username= |
delegate |
[delegate_voters ][delegate_voters] |
/api/delegates/voters?publicKey= |
accounts |
[transaction ][transaction] |
/api/transactions/get?id= |
- |
[transactions ][transactions] |
/api/transactions? |
- |
[uri ][uri] |
/api/ |
- |
default:
log.error(`ADM api Not implemented yet`);
return false;
примеры:
const txChat = (await api.get(uri
, chats/get/?recipientId=
+ Store.user.ADM.address + &orderBy=timestamp:desc&fromHeight=
+ (Store.lastHeight - 5))).transactions;
const txTrx = (await api.get(`transactions`, `fromHeight=` + (Store.lastHeight - 5) + `&and:recipientId=` + Store.user.ADM.address + `&and:type=0`)).transactions;
const lastBlock = (await api.get(uri
, blocks
)).blocks[0];
метод https://github.com/Adamant-im/adamant-api-jsclient/blob/master/groups/syncGet.js выполняет асинхронно http-запрос
примеры
const data = await api.syncGet(config.infoservice + /get
, true);
const resp = await api.syncGet(/api/states/get?senderId=${admAddress}&key=${coin.toLowerCase()}:address
);
метод https://github.com/Adamant-im/adamant-api-jsclient/blob/master/groups/send.js
примеры
const result = await $u[outCurrency].send({
address: senderKvsOutAddress,
value: outAmount,
comment: Hey, you are lucky! Waiting for new bets!
// if ADM
});
log.info(Reward payment result: ${JSON.stringify(result, 0, 2)}.
);
const {
address,
value,
comment
} = params;
console.log(`Send ${value} ADM to ${address} with comment:`, comment);
let res;
if (comment){
res = api.send(User.passPhrase, address, comment, `message`, null, value);
} else {
res = api.send(User.passPhrase, address, value, null, comment);
}
console.log(`Send result:`, res);
if (!res) {
return {
success: false
};
}
return {
success: res.success,
hash: res.transactionId
};
sendAdmMsg(address, msg, type = message
) {
if (msg && !config.isDev || true) {
try {
let msg_markdown = msg.replace(/[^*]*[^*]/g, **
);
return api.send(config.passPhrase, address, msg_markdown, type).success || false;
} catch (e) {
return false;
}
}
},
метод https://github.com/Adamant-im/adamant-api-jsclient/blob/master/groups/decodeMsg.js
примеры
const chat = tx.asset.chat; if (chat){ msg = api.decodeMsg(chat.message, tx.senderPublicKey, config.passPhrase, chat.own_message).trim(); }