Skip to content

Commit

Permalink
Merge pull request #104 from DcentWallet/feature/#103_Algorand
Browse files Browse the repository at this point in the history
Feature/#103 algorand
  • Loading branch information
KyungeunKim committed Nov 29, 2023
2 parents b02ad80 + 53b8882 commit 91a0ac1
Show file tree
Hide file tree
Showing 30 changed files with 550 additions and 36 deletions.
91 changes: 91 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
| v0.13.1 | 2023. 05. 17 | Fixed fee display issue |
| v0.14.0 | 2023. 05. 25 | add Polkadot & Comsmos & Coreum & Near Token |
| v0.14.1 | 2023. 05. 25 | Fix Polkadot decimals |
| v0.14.2 | 2023. 11. 20 | add Algorand transaction function |

## 1. INTRODUCTION

Expand Down Expand Up @@ -1862,4 +1863,94 @@ For broadcast the sign transaction, you must reconstruct transaction include `Tx
}
```

**getAlgorandSignedTransaction()**

- This fuction for :

- ALGORAND(ALGO)
- ALGORAND ASSET(ALGO-ASSET)
- ALGORAND APP(ALGO-APP)
- Parameters :

- unsignedTx: unsigned hexadecimal tx [Algorand Developer Transaction Reference Docs](https://developer.algorand.org/docs/get-details/transactions/transactions/)
- path: key path, wallet sign with that private key with a given key path (BIP32 ex) "m/44'/283'/0'/0/0").
- fee: fee, It is fee that wallet displays on the screen.
- symbol: symbol, It is a symbol that the wallet displays on the screen.
- decimals: havah or havah token's decimals.
- optionParam: hexadecimal value of the havah method type is used only in havah token.
- '00' : ALGORAND Transfer
- '01' : ALGORAND ASSET Transfer
- '02' : ALGORAND ASSET OPTIN
- '03' : ALGORAND APP Contract call
- '04' : ALGORAND APP OPTIN
- '05' : ALGORAND ASSET FT Create
- '06' : ALGORAND ASSET NFT Create
- Requirements:

- `D'CENT Bridge` version 1.5.0 or higher is required.
- D'CENT Biometric Wallet version 2.29.1. or higher is required.
- Useage:

```js
import algosdk from 'algosdk'

const algodClient = new algosdk.Algodv2('', 'https://mainnet-api.algonode.cloud', '')
const indexerClient = new algosdk.Indexer('', 'https://mainnet-idx.algonode.cloud', '')

// An account for Algorand should keep cost for maintaining the account.
const balanceInfo = await algodClient.accountInformation(walletAddress).do()
const blanace = balanceInfo.amount.toString()
const maintenance = balaceInfo['min-balance'].toString()

// Make a transaction
const suggestedParams = await algodClient.getTransactionParams().do()
const tx = algosdk.makePaymentTxnWithSuggestedParamsFromObject({
suggestedParams,
from: walletAddress,
to: someWhere,
amount: value, // Unit is microAlgos
memo: new Uint8Array(Buffer.from('Something what you want', 'hex')) || undefined
})

// Create JSON-formatted data for getting a signature
const unsignedRawData = Uint8ArrayToHex(tx.bytesToSign())
const sigHash = rawData

const transactionJson = {
coinType: DcentWebConnector.coinType.ALGORAND,
sigHash: unsignedRawData,
path: `m/44'/283'/0'/0/0`,
decimals: 6, // for ALGORAND
fee: tx.fee,
symbol: 'ALGO',
optionParams: '00'
}

var result
try {
result = await DcentWebConnector.getAlgorandSignedTransaction(transactionJson);
} catch (e) {
console.log(e)
result = e
}
```

- Returned response object:

```json
{
"header": {
"version": "1.0",
"response_from": "algorand",
"status": "success"
},
"body": {
"command": "transaction",
"parameter": {
"signed_tx": "31aa13b5e04cb6fc6381ea0520bf7f6727ebdb6e96cd7ca8625bb3e3dd36cf0e2cee4ece13aa9f7ddc09ee10c74aa00af954201829d8016317f10f5a921dcc0d"
}
}
}
```

Please Refer to the `index.html` to learn more about how to use the SDK APIs. There is an Web project using our Web SDK.
24 changes: 24 additions & 0 deletions info/supported_union_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,29 @@
{
"name": "havah-hsp20-testnet",
"supportVersion": "2.26.0"
},
{
"name": "algorand",
"supportVersion": "2.29.1"
},
{
"name": "algo-testnet",
"supportVersion": "2.29.1"
},
{
"name": "algo-asset",
"supportVersion": "2.29.1"
},
{
"name": "algo-asset-test",
"supportVersion": "2.29.1"
},
{
"name": "algo-app",
"supportVersion": "2.29.1"
},
{
"name": "algo-app-test",
"supportVersion": "2.29.1"
}
]
82 changes: 50 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^2.0.1",
"expect-puppeteer": "^4.4.0",
"hi-base32": "^0.5.1",
"html-webpack-plugin": "^3.2.0",
"jest": "^25.4.0",
"jest-puppeteer": "^4.4.0",
Expand All @@ -80,6 +81,7 @@
"puppeteer": "^2.1.1",
"regenerator-runtime": "^0.13.3",
"thor-devkit": "^2.0.7",
"tweetnacl": "^1.0.3",
"webpack": "^4.39.1",
"webpack-cli": "^3.3.6",
"webpack-dev-server": "^3.11.0"
Expand Down
Loading

0 comments on commit 91a0ac1

Please sign in to comment.