forked from bosagora/dms-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e755b2f
commit 08eb577
Showing
11 changed files
with
144 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ coverage | |
*.tgz | ||
*.log | ||
.turbo | ||
.hidden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"shopId": "0x00011936a68f7c26797fa2ab64d444ea82c2fb1af36cdea6d4ff845da635f287", | ||
"address": "0xB6f69F0e9e70034ba0578C542476cC13eF739269", | ||
"privateKey": "0x595f911dcf0845cb1f2d0e5cec9f1ccfd62fa199ebeae215a72aa56014edbb32" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"shopId": "0x00011f2355a63165608a0f1c00cf1a03183cf9e7e0becb874092f1cdf9db8aa0", | ||
"address": "0x9b3ABc653D15B5a0f4E43E6340096C1C9BB2CA2f", | ||
"privateKey": "0xc3bc6d1141896f1729ece9c7a8bb97c6222cac8e7d902317746b073a369a263e" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[{ | ||
"shopId": "0x00011936a68f7c26797fa2ab64d444ea82c2fb1af36cdea6d4ff845da635f287", | ||
"address": "0xB6f69F0e9e70034ba0578C542476cC13eF739269", | ||
"privateKey": "0x595f911dcf0845cb1f2d0e5cec9f1ccfd62fa199ebeae215a72aa56014edbb32", | ||
"name": "상점1", | ||
"currency": "php" | ||
},{ | ||
"shopId": "0x00011f2355a63165608a0f1c00cf1a03183cf9e7e0becb874092f1cdf9db8aa0", | ||
"address": "0x9b3ABc653D15B5a0f4E43E6340096C1C9BB2CA2f", | ||
"privateKey": "0xc3bc6d1141896f1729ece9c7a8bb97c6222cac8e7d902317746b073a369a263e", | ||
"name": "상점2", | ||
"currency": "php" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"phone": "+82 10-9520-1803", | ||
"address": "0x9a568e50556e7d51d1d477b22C28a099d33Ea04f", | ||
"privateKey": "0x00e8b7fdbed0d29a71339ca7699ff3982708867725e8c49e04ced69222189551" | ||
"address": "0x5A3Fc8990417b3e6ddCdAE0E8039E798A609Ef84", | ||
"privateKey": "0x1f38c07e88ca6bc2f7790f09a27bfc39f4524cf2a322d003435392cfa0d6dae3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Helper } from "../utils"; | ||
import { Client, Context, ContextBuilder, ContractUtils, NormalSteps } from "acc-sdk-client-v2"; | ||
import fs from "fs"; | ||
import { Wallet } from "ethers"; | ||
|
||
async function main() { | ||
const shopInfos = JSON.parse(fs.readFileSync("./data/shop_infos.json", "utf8")).map( | ||
(m: { shopId: string; privateKey: string; name: string; currency: string }) => { | ||
return { | ||
shopId: m.shopId, | ||
wallet: new Wallet(m.privateKey), | ||
name: m.name, | ||
currency: m.currency, | ||
}; | ||
} | ||
); | ||
for (const shopInfo of shopInfos) { | ||
const contextParams = ContextBuilder.buildContextParams(Helper.NETWORK, shopInfo.wallet.privateKey); | ||
if (Helper.RELAY_ENDPOINT !== "") contextParams.relayEndpoint = Helper.RELAY_ENDPOINT; | ||
if (Helper.WEB3_ENDPOINT !== "") contextParams.web3Provider = Helper.WEB3_ENDPOINT; | ||
const context: Context = new Context(contextParams); | ||
const client = new Client(context); | ||
console.log("상점 데이타를 추가합니다."); | ||
|
||
for await (const step of client.shop.add(shopInfo.shopId, shopInfo.name, shopInfo.currency)) { | ||
switch (step.key) { | ||
case NormalSteps.PREPARED: | ||
console.log("NormalSteps.PREPARED"); | ||
break; | ||
case NormalSteps.SENT: | ||
console.log("NormalSteps.SENT"); | ||
break; | ||
case NormalSteps.DONE: | ||
console.log("NormalSteps.DONE"); | ||
break; | ||
default: | ||
throw new Error("Unexpected add shop step: " + JSON.stringify(step, null, 2)); | ||
} | ||
} | ||
|
||
await ContractUtils.delay(1000); | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Helper } from "../utils"; | ||
import { Amount, Client, Context, ContextBuilder, NormalSteps } from "acc-sdk-client-v2"; | ||
import { BOACoin } from "../../src/Amount"; | ||
import { BigNumber } from "@ethersproject/bignumber"; | ||
|
||
const beautify = require("beautify"); | ||
|
||
async function main() { | ||
const shopInfo = Helper.loadShopInfo(); | ||
console.log(`shopId: ${shopInfo.shopId}`); | ||
console.log(`wallet.address: ${shopInfo.wallet.address}`); | ||
|
||
const contextParams = ContextBuilder.buildContextParams(Helper.NETWORK, shopInfo.wallet.privateKey); | ||
if (Helper.RELAY_ENDPOINT !== "") contextParams.relayEndpoint = Helper.RELAY_ENDPOINT; | ||
if (Helper.WEB3_ENDPOINT !== "") contextParams.web3Provider = Helper.WEB3_ENDPOINT; | ||
const context: Context = new Context(contextParams); | ||
const client = new Client(context); | ||
|
||
console.log("상점 정보를 요청합니다."); | ||
const info = await client.shop.getShopInfo(shopInfo.shopId); | ||
const refundable = await client.shop.getRefundableAmount(shopInfo.shopId); | ||
|
||
console.log("처리결과입니다."); | ||
console.log(`shopId: ${info.shopId}`); | ||
console.log(`name: ${info.name}`); | ||
console.log(`currency: ${info.currency}`); | ||
console.log(`account: ${info.account}`); | ||
console.log(`delegator: ${info.delegator}`); | ||
console.log(`providedAmount: ${new BOACoin(info.providedAmount).toDisplayString(true, 2)}`); | ||
console.log(`usedAmount: ${new BOACoin(info.usedAmount).toDisplayString(true, 2)}`); | ||
console.log(`refundedAmount: ${new BOACoin(info.refundedAmount).toDisplayString(true, 2)}`); | ||
console.log(`refundableAmount: ${new BOACoin(refundable.refundableAmount).toDisplayString(true, 2)}`); | ||
|
||
if (refundable.refundableAmount.gt(BigNumber.from(0))) { | ||
for await (const step of client.shop.refund(shopInfo.shopId, refundable.refundableAmount)) { | ||
switch (step.key) { | ||
case NormalSteps.PREPARED: | ||
console.log(`NormalSteps.PREPARED`); | ||
console.log(`step.shopId: ${step.shopId}`); | ||
console.log(`step.signature: ${step.signature}`); | ||
break; | ||
case NormalSteps.SENT: | ||
console.log(`NormalSteps.SENT`); | ||
console.log(`step.txHash: ${step.txHash}`); | ||
break; | ||
case NormalSteps.DONE: | ||
console.log(`NormalSteps.DONE`); | ||
console.log(`step.refundAmount: ${step.refundAmount.toString()}`); | ||
break; | ||
default: | ||
throw new Error("Unexpected open withdrawal step: " + JSON.stringify(step, null, 2)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
process.exitCode = 1; | ||
}); |