diff --git a/packages/contracts/contracts/controllers/LoyaltyProvider.sol b/packages/contracts/contracts/controllers/LoyaltyProvider.sol index 7358b35a..581db060 100644 --- a/packages/contracts/contracts/controllers/LoyaltyProvider.sol +++ b/packages/contracts/contracts/controllers/LoyaltyProvider.sol @@ -190,9 +190,9 @@ contract LoyaltyProvider is LoyaltyProviderStorage, Initializable, OwnableUpgrad ) ); address recover = ECDSA.recover(ECDSA.toEthSignedMessageHash(purchaseDataHash), data.signature); - address assistant = ledgerContract.assistantOf(data.sender); - if ((assistant == address(0x0)) && (recover != data.sender)) continue; - if ((assistant != address(0x0)) && (recover != assistant)) continue; + address agent = ledgerContract.provisioningAgentOf(data.sender); + if ((agent == address(0x0)) && (recover != data.sender)) continue; + if ((agent != address(0x0)) && (recover != agent)) continue; uint256 loyaltyValue = data.loyalty; uint256 loyaltyPoint = currencyRateContract.convertCurrencyToPoint(loyaltyValue, data.currency); @@ -285,19 +285,17 @@ contract LoyaltyProvider is LoyaltyProviderStorage, Initializable, OwnableUpgrad if (recurve1 == _provider) { sender = _provider; } else { - address assistant = ledgerContract.assistantOf(_provider); - require(assistant != address(0x0), "1501"); + address agent = ledgerContract.provisioningAgentOf(_provider); + require(agent != address(0x0), "1501"); address recurve2 = ECDSA.recover( ECDSA.toEthSignedMessageHash( - keccak256( - abi.encode(_provider, _receiver, _point, block.chainid, ledgerContract.nonceOf(assistant)) - ) + keccak256(abi.encode(_provider, _receiver, _point, block.chainid, ledgerContract.nonceOf(agent))) ), _signature ); - require(recurve2 == assistant, "1501"); - sender = assistant; + require(recurve2 == agent, "1501"); + sender = agent; } ledgerContract.providePoint( @@ -333,19 +331,17 @@ contract LoyaltyProvider is LoyaltyProviderStorage, Initializable, OwnableUpgrad if (recurve1 == _provider) { sender = _provider; } else { - address assistant = ledgerContract.assistantOf(_provider); - require(assistant != address(0x0), "1501"); + address agent = ledgerContract.provisioningAgentOf(_provider); + require(agent != address(0x0), "1501"); address recurve2 = ECDSA.recover( ECDSA.toEthSignedMessageHash( - keccak256( - abi.encode(_provider, _phoneHash, _point, block.chainid, ledgerContract.nonceOf(assistant)) - ) + keccak256(abi.encode(_provider, _phoneHash, _point, block.chainid, ledgerContract.nonceOf(agent))) ), _signature ); - require(recurve2 == assistant, "1501"); - sender = assistant; + require(recurve2 == agent, "1501"); + sender = agent; } address receiver = linkContract.toAddress(_phoneHash); diff --git a/packages/contracts/contracts/interfaces/ILedger.sol b/packages/contracts/contracts/interfaces/ILedger.sol index f66a7fb7..d2f5fe23 100644 --- a/packages/contracts/contracts/interfaces/ILedger.sol +++ b/packages/contracts/contracts/interfaces/ILedger.sol @@ -71,5 +71,5 @@ interface ILedger { function isProvider(address _account) external view returns (bool); - function assistantOf(address _account) external view returns (address); + function provisioningAgentOf(address _account) external view returns (address); } diff --git a/packages/contracts/contracts/ledger/Ledger.sol b/packages/contracts/contracts/ledger/Ledger.sol index 4f922653..7164814d 100644 --- a/packages/contracts/contracts/ledger/Ledger.sol +++ b/packages/contracts/contracts/ledger/Ledger.sol @@ -67,7 +67,7 @@ contract Ledger is LedgerStorage, Initializable, OwnableUpgradeable, UUPSUpgrade event RegisteredProvider(address provider); event UnregisteredProvider(address provider); - event RegisteredAssistant(address provider, address assistant); + event RegisteredProvisioningAgent(address account, address agent); struct ManagementAddresses { address system; @@ -497,33 +497,33 @@ contract Ledger is LedgerStorage, Initializable, OwnableUpgradeable, UUPSUpgrade protocolFeeAccount = _account; } - function registerProvider(address _provider) external { + function registerProvider(address _account) external { require(_msgSender() == owner(), "1050"); - providers[_provider] = true; - emit RegisteredProvider(_provider); + providers[_account] = true; + emit RegisteredProvider(_account); } - function unregisterProvider(address _provider) external { + function unregisterProvider(address _account) external { require(_msgSender() == owner(), "1050"); - providers[_provider] = false; - emit UnregisteredProvider(_provider); - } - - function registerAssistant(address _provider, address _assistant, bytes calldata _signature) external { - require(providers[_provider], "1054"); - bytes32 dataHash = keccak256(abi.encode(_provider, _assistant, block.chainid, nonce[_provider])); - require(ECDSA.recover(ECDSA.toEthSignedMessageHash(dataHash), _signature) == _provider, "1501"); - assistants[_provider] = _assistant; - nonce[_provider]++; - - emit RegisteredAssistant(_provider, _assistant); + providers[_account] = false; + emit UnregisteredProvider(_account); } function isProvider(address _account) external view override returns (bool) { return providers[_account]; } - function assistantOf(address _account) external view override returns (address) { - return assistants[_account]; + function registerProvisioningAgent(address _account, address _agent, bytes calldata _signature) external { + require(providers[_account], "1054"); + bytes32 dataHash = keccak256(abi.encode(_account, _agent, block.chainid, nonce[_account])); + require(ECDSA.recover(ECDSA.toEthSignedMessageHash(dataHash), _signature) == _account, "1501"); + provisioningAgents[_account] = _agent; + nonce[_account]++; + + emit RegisteredProvisioningAgent(_account, _agent); + } + + function provisioningAgentOf(address _account) external view override returns (address) { + return provisioningAgents[_account]; } } diff --git a/packages/contracts/contracts/ledger/LedgerStorage.sol b/packages/contracts/contracts/ledger/LedgerStorage.sol index 682eacd9..1a586cfb 100644 --- a/packages/contracts/contracts/ledger/LedgerStorage.sol +++ b/packages/contracts/contracts/ledger/LedgerStorage.sol @@ -19,7 +19,7 @@ contract LedgerStorage { mapping(address => uint256) internal liquidity; mapping(address => bool) internal providers; - mapping(address => address) internal assistants; + mapping(address => address) internal provisioningAgents; address public systemAccount; address public paymentFeeAccount; diff --git a/packages/contracts/deploy/side_chain_devnet/deploy.ts b/packages/contracts/deploy/side_chain_devnet/deploy.ts index 1d7f7b19..7505a449 100644 --- a/packages/contracts/deploy/side_chain_devnet/deploy.ts +++ b/packages/contracts/deploy/side_chain_devnet/deploy.ts @@ -907,7 +907,7 @@ async function deployLedger(accounts: IAccount, deployment: Deployments) { { const nonce = await contract.nonceOf(accounts.system.address); - const message = ContractUtils.getRegisterAssistanceMessage( + const message = ContractUtils.getRegisterAgentMessage( accounts.system.address, accounts.publisher.address, nonce, @@ -916,11 +916,11 @@ async function deployLedger(accounts: IAccount, deployment: Deployments) { const signature = await ContractUtils.signMessage(accounts.system, message); const tx = await contract .connect(accounts.certifiers[0]) - .registerAssistant(accounts.system.address, accounts.publisher.address, signature); - console.log(`Register assistant address of system (tx: ${tx.hash})...`); + .registerProvisioningAgent(accounts.system.address, accounts.publisher.address, signature); + console.log(`Register agent address of system (tx: ${tx.hash})...`); // await tx.wait(); - const value = await contract.assistantOf(accounts.system.address); + const value = await contract.provisioningAgentOf(accounts.system.address); console.log("Assistance of System Account: ", value); } } diff --git a/packages/contracts/src/utils/ContractUtils.ts b/packages/contracts/src/utils/ContractUtils.ts index f977cedd..2e9857ce 100644 --- a/packages/contracts/src/utils/ContractUtils.ts +++ b/packages/contracts/src/utils/ContractUtils.ts @@ -663,15 +663,15 @@ export class ContractUtils { return arrayify(keccak256(encodedResult)); } - public static getRegisterAssistanceMessage( - provider: string, - assistance: string, + public static getRegisterAgentMessage( + account: string, + agent: string, nonce: BigNumberish, chainId: BigNumberish ): Uint8Array { const encodedResult = defaultAbiCoder.encode( ["address", "address", "uint256", "uint256"], - [provider, assistance, chainId, nonce] + [account, agent, chainId, nonce] ); return arrayify(keccak256(encodedResult)); } diff --git a/packages/contracts/test/08-Ledger-Provider.test.ts b/packages/contracts/test/08-Ledger-Provider.test.ts index d407f8f1..bcb39474 100644 --- a/packages/contracts/test/08-Ledger-Provider.test.ts +++ b/packages/contracts/test/08-Ledger-Provider.test.ts @@ -356,9 +356,9 @@ describe("Test for Ledger", () => { }); it("Register Assistance", async () => { - expect(await ledgerContract.assistantOf(deployments.accounts.users[0].address)).equal(AddressZero); + expect(await ledgerContract.provisioningAgentOf(deployments.accounts.users[0].address)).equal(AddressZero); const nonce = await ledgerContract.nonceOf(deployments.accounts.users[0].address); - const message = ContractUtils.getRegisterAssistanceMessage( + const message = ContractUtils.getRegisterAgentMessage( deployments.accounts.users[0].address, deployments.accounts.users[2].address, nonce, @@ -368,29 +368,29 @@ describe("Test for Ledger", () => { await expect( ledgerContract .connect(deployments.accounts.deployer) - .registerAssistant( + .registerProvisioningAgent( deployments.accounts.users[0].address, deployments.accounts.users[2].address, signature ) ) - .emit(ledgerContract, "RegisteredAssistant") + .emit(ledgerContract, "RegisteredProvisioningAgent") .withNamedArgs({ - provider: deployments.accounts.users[0].address, - assistant: deployments.accounts.users[2].address, + account: deployments.accounts.users[0].address, + agent: deployments.accounts.users[2].address, }); - expect(await ledgerContract.assistantOf(deployments.accounts.users[0].address)).equal( + expect(await ledgerContract.provisioningAgentOf(deployments.accounts.users[0].address)).equal( deployments.accounts.users[2].address ); }); - it("Provide point - assistance", async () => { + it("Provide point - agent", async () => { const providePoint = Amount.make(100, 18).value; - const assistance = deployments.accounts.users[2]; + const agent = deployments.accounts.users[2]; const provider = deployments.accounts.users[0]; const receiver = deployments.accounts.users[3]; - const nonce = await ledgerContract.nonceOf(assistance.address); + const nonce = await ledgerContract.nonceOf(agent.address); const message = ContractUtils.getProvidePointToAddressMessage( provider.address, receiver.address, @@ -398,7 +398,7 @@ describe("Test for Ledger", () => { nonce, hre.ethers.provider.network.chainId ); - const signature = await ContractUtils.signMessage(assistance, message); + const signature = await ContractUtils.signMessage(agent, message); await expect( providerContract .connect(deployments.accounts.certifiers[0]) diff --git a/packages/relay/scripts/provider/send.ts b/packages/relay/scripts/provider/send.ts index 2408e46d..da7f4bb2 100644 --- a/packages/relay/scripts/provider/send.ts +++ b/packages/relay/scripts/provider/send.ts @@ -35,8 +35,8 @@ async function main() { const provider = new Wallet("0x70438bc3ed02b5e4b76d496625cb7c06d6b7bf4362295b16fdfe91a046d4586c"); // 0x64D111eA9763c93a003cef491941A011B8df5a49 const receiver = new Wallet("0x595f911dcf0845cb1f2d0e5cec9f1ccfd62fa199ebeae215a72aa56014edbb32"); // 0xB6f69F0e9e70034ba0578C542476cC13eF739269 - const assistant = await sideLedgerContract.assistantOf(provider.address); - console.log(`assistant: ${assistant}`); + const agent = await sideLedgerContract.provisioningAgentOf(provider.address); + console.log(`agent: ${agent}`); const balance1 = await sideLedgerContract.pointBalanceOf(receiver.address); const pointAmount = Amount.make(100, 18).value; diff --git a/packages/relay/scripts/provider/send_to_phone.ts b/packages/relay/scripts/provider/send_to_phone.ts index 45d1ab49..cc0b7a92 100644 --- a/packages/relay/scripts/provider/send_to_phone.ts +++ b/packages/relay/scripts/provider/send_to_phone.ts @@ -35,8 +35,8 @@ async function main() { const provider = new Wallet("0x70438bc3ed02b5e4b76d496625cb7c06d6b7bf4362295b16fdfe91a046d4586c"); // 0x64D111eA9763c93a003cef491941A011B8df5a49 const receiver = ContractUtils.getPhoneHash("+82 10-9000-2000"); - const assistant = await sideLedgerContract.assistantOf(provider.address); - console.log(`assistant: ${assistant}`); + const agent = await sideLedgerContract.provisioningAgentOf(provider.address); + console.log(`agent: ${agent}`); const balance1 = await sideLedgerContract.unPayablePointBalanceOf(receiver); const pointAmount = Amount.make(100, 18).value; diff --git a/packages/relay/src/routers/ProviderRouter.ts b/packages/relay/src/routers/ProviderRouter.ts index b286d5ed..82a5ea82 100644 --- a/packages/relay/src/routers/ProviderRouter.ts +++ b/packages/relay/src/routers/ProviderRouter.ts @@ -141,22 +141,22 @@ export class ProviderRouter { ); this.app.post( - "/v1/provider/assistant/register", + "/v1/provider/agent/register", [ body("provider").exists().trim().isEthereumAddress(), - body("assistant").exists().trim().isEthereumAddress(), + body("agent").exists().trim().isEthereumAddress(), body("signature") .exists() .trim() .matches(/^(0x)[0-9a-f]{130}$/i), ], - this.provider_assistant_register.bind(this) + this.provider_agent_register.bind(this) ); this.app.get( - "/v1/provider/assistant/:provider", + "/v1/provider/agent/:provider", [param("provider").exists().trim().isEthereumAddress()], - this.provider_assistant.bind(this) + this.provider_agent.bind(this) ); } @@ -269,10 +269,10 @@ export class ProviderRouter { const amount: BigNumber = BigNumber.from(req.body.amount); const signature: string = String(req.body.signature).trim(); - let assistant = await this.contractManager.sideLedgerContract.assistantOf(provider); - if (assistant === AddressZero) assistant = provider; + let agent = await this.contractManager.sideLedgerContract.provisioningAgentOf(provider); + if (agent === AddressZero) agent = provider; - const nonce = await this.contractManager.sideLedgerContract.nonceOf(assistant); + const nonce = await this.contractManager.sideLedgerContract.nonceOf(agent); const message = ContractUtils.getProvidePointToAddressMessage( provider, receiver, @@ -280,7 +280,7 @@ export class ProviderRouter { nonce, this.contractManager.sideChainId ); - if (!ContractUtils.verifyMessage(assistant, message, signature)) + if (!ContractUtils.verifyMessage(agent, message, signature)) return res.status(200).json(ResponseMessage.getErrorMessage("1501")); const tx = await this.contractManager.sideLoyaltyProviderContract .connect(signerItem.signer) @@ -312,10 +312,10 @@ export class ProviderRouter { const amount: BigNumber = BigNumber.from(req.body.amount); const signature: string = String(req.body.signature).trim(); - let assistant = await this.contractManager.sideLedgerContract.assistantOf(provider); - if (assistant === AddressZero) assistant = provider; + let agent = await this.contractManager.sideLedgerContract.provisioningAgentOf(provider); + if (agent === AddressZero) agent = provider; - const nonce = await this.contractManager.sideLedgerContract.nonceOf(assistant); + const nonce = await this.contractManager.sideLedgerContract.nonceOf(agent); const message = ContractUtils.getProvidePointToPhoneMessage( provider, receiver, @@ -323,7 +323,7 @@ export class ProviderRouter { nonce, this.contractManager.sideChainId ); - if (!ContractUtils.verifyMessage(assistant, message, signature)) + if (!ContractUtils.verifyMessage(agent, message, signature)) return res.status(200).json(ResponseMessage.getErrorMessage("1501")); const tx = await this.contractManager.sideLoyaltyProviderContract .connect(signerItem.signer) @@ -340,8 +340,8 @@ export class ProviderRouter { } } - private async provider_assistant_register(req: express.Request, res: express.Response) { - logger.http(`POST /v1/provider/assistant/register ${req.ip}:${JSON.stringify(req.body)}`); + private async provider_agent_register(req: express.Request, res: express.Response) { + logger.http(`POST /v1/provider/agent/register ${req.ip}:${JSON.stringify(req.body)}`); const errors = validationResult(req); if (!errors.isEmpty()) { @@ -351,13 +351,13 @@ export class ProviderRouter { const signerItem = await this.getRelaySigner(this.contractManager.sideChainProvider); try { const provider: string = String(req.body.provider).trim(); - const assistant: string = String(req.body.assistant).trim(); + const agent: string = String(req.body.agent).trim(); const signature: string = String(req.body.signature).trim(); const nonce = await this.contractManager.sideLedgerContract.nonceOf(provider); - const message = ContractUtils.getRegisterAssistanceMessage( + const message = ContractUtils.getRegisterAgentMessage( provider, - assistant, + agent, nonce, this.contractManager.sideChainId ); @@ -365,12 +365,12 @@ export class ProviderRouter { return res.status(200).json(ResponseMessage.getErrorMessage("1501")); const tx = await this.contractManager.sideLedgerContract .connect(signerItem.signer) - .registerAssistant(provider, assistant, signature); + .registerProvisioningAgent(provider, agent, signature); this.metrics.add("success", 1); - return res.status(200).json(this.makeResponseData(0, { provider, assistant, txHash: tx.hash })); + return res.status(200).json(this.makeResponseData(0, { provider, agent, txHash: tx.hash })); } catch (error: any) { const msg = ResponseMessage.getEVMErrorMessage(error); - logger.error(`POST /v1/provider/assistant/register : ${msg.error.message}`); + logger.error(`POST /v1/provider/agent/register : ${msg.error.message}`); this.metrics.add("failure", 1); return res.status(200).json(this.makeResponseData(msg.code, undefined, msg.error)); } finally { @@ -378,8 +378,8 @@ export class ProviderRouter { } } - private async provider_assistant(req: express.Request, res: express.Response) { - logger.http(`GET /v1/provider/assistant/:provider ${req.ip}:${JSON.stringify(req.params)}`); + private async provider_agent(req: express.Request, res: express.Response) { + logger.http(`GET /v1/provider/agent/:provider ${req.ip}:${JSON.stringify(req.params)}`); const errors = validationResult(req); if (!errors.isEmpty()) { @@ -388,12 +388,12 @@ export class ProviderRouter { try { const provider: string = String(req.params.provider).trim(); - const assistant = await this.contractManager.sideLedgerContract.assistantOf(provider); + const agent = await this.contractManager.sideLedgerContract.provisioningAgentOf(provider); this.metrics.add("success", 1); - return res.status(200).json(this.makeResponseData(0, { provider, assistant })); + return res.status(200).json(this.makeResponseData(0, { provider, agent })); } catch (error: any) { const msg = ResponseMessage.getEVMErrorMessage(error); - logger.error(`GET /v1/provider/assistant/:account : ${msg.error.message}`); + logger.error(`GET /v1/provider/agent/:account : ${msg.error.message}`); this.metrics.add("failure", 1); return res.status(200).json(this.makeResponseData(msg.code, undefined, msg.error)); } diff --git a/packages/relay/src/routers/TokenRouter.ts b/packages/relay/src/routers/TokenRouter.ts index 1581d2b9..4fdf3a44 100644 --- a/packages/relay/src/routers/TokenRouter.ts +++ b/packages/relay/src/routers/TokenRouter.ts @@ -510,7 +510,7 @@ export class TokenRouter { } const isProvider = await this.contractManager.sideLedgerContract.isProvider(account); - const assistant = await this.contractManager.sideLedgerContract.assistantOf(account); + const agent = await this.contractManager.sideLedgerContract.provisioningAgentOf(account); const symbol = await this.contractManager.sideTokenContract.symbol(); const name = await this.contractManager.sideTokenContract.name(); @@ -557,7 +557,7 @@ export class TokenRouter { }, provider: { enable: isProvider, - assistant, + agent, }, ledger: { point: { balance: pointBalance.toString(), value: pointValue.toString() }, diff --git a/packages/relay/src/utils/ContractUtils.ts b/packages/relay/src/utils/ContractUtils.ts index 5140d38d..547ed169 100644 --- a/packages/relay/src/utils/ContractUtils.ts +++ b/packages/relay/src/utils/ContractUtils.ts @@ -775,15 +775,15 @@ export class ContractUtils { return arrayify(keccak256(encodedResult)); } - public static getRegisterAssistanceMessage( - provider: string, - assistance: string, + public static getRegisterAgentMessage( + account: string, + agent: string, nonce: BigNumberish, chainId: BigNumberish ): Uint8Array { const encodedResult = defaultAbiCoder.encode( ["address", "address", "uint256", "uint256"], - [provider, assistance, chainId, nonce] + [account, agent, chainId, nonce] ); return arrayify(keccak256(encodedResult)); } diff --git a/packages/relay/test/LoyaltyProvider.test.ts b/packages/relay/test/LoyaltyProvider.test.ts index bf6c86ff..430f6057 100644 --- a/packages/relay/test/LoyaltyProvider.test.ts +++ b/packages/relay/test/LoyaltyProvider.test.ts @@ -115,7 +115,7 @@ describe("Test of LoyaltyProvider", function () { ); expect(response.data.data.provider.enable).to.deep.equal(false); - expect(response.data.data.provider.assistant).to.deep.equal(AddressZero); + expect(response.data.data.provider.agent).to.deep.equal(AddressZero); }); it("Register Provide", async () => { @@ -136,7 +136,7 @@ describe("Test of LoyaltyProvider", function () { ); expect(response.data.data.provider.enable).to.deep.equal(true); - expect(response.data.data.provider.assistant).to.deep.equal(AddressZero); + expect(response.data.data.provider.agent).to.deep.equal(AddressZero); }); it("Balance of Provider", async () => { @@ -221,26 +221,26 @@ describe("Test of LoyaltyProvider", function () { ); }); - it("Register assistant", async () => { + it("Register agent", async () => { const provider = deployments.accounts.users[0]; const response1 = await client.get( - URI(serverURL).directory(`/v1/provider/assistant/${provider.address}`).toString() + URI(serverURL).directory(`/v1/provider/agent/${provider.address}`).toString() ); expect(response1.data.data.provider).to.deep.equal(provider.address); - expect(response1.data.data.assistant).to.deep.equal(AddressZero); + expect(response1.data.data.agent).to.deep.equal(AddressZero); - const assistant = deployments.accounts.users[1]; + const agent = deployments.accounts.users[1]; const nonce = await contractManager.sideLedgerContract.nonceOf(provider.address); - const message = ContractUtils.getRegisterAssistanceMessage( + const message = ContractUtils.getRegisterAgentMessage( provider.address, - assistant.address, + agent.address, nonce, contractManager.sideChainId ); const signature = await ContractUtils.signMessage(provider, message); - const response2 = await client.post(URI(serverURL).directory(`/v1/provider/assistant/register`).toString(), { + const response2 = await client.post(URI(serverURL).directory(`/v1/provider/agent/register`).toString(), { provider: provider.address, - assistant: assistant.address, + agent: agent.address, signature, }); expect(response2.data.code).to.equal(0); @@ -248,10 +248,10 @@ describe("Test of LoyaltyProvider", function () { expect(response2.data.data.txHash).to.match(/^0x[A-Fa-f0-9]{64}$/i); const response3 = await client.get( - URI(serverURL).directory(`/v1/provider/assistant/${provider.address}`).toString() + URI(serverURL).directory(`/v1/provider/agent/${provider.address}`).toString() ); expect(response3.data.data.provider).to.deep.equal(provider.address); - expect(response3.data.data.assistant).to.deep.equal(assistant.address); + expect(response3.data.data.agent).to.deep.equal(agent.address); }); it("Check Summary of Account", async () => { @@ -260,18 +260,18 @@ describe("Test of LoyaltyProvider", function () { ); expect(response.data.data.provider.enable).to.deep.equal(true); - expect(response.data.data.provider.assistant).to.deep.equal(deployments.accounts.users[1].address); + expect(response.data.data.provider.agent).to.deep.equal(deployments.accounts.users[1].address); }); it("Provide Point for Address by Assistant", async () => { const provider = deployments.accounts.users[0]; - const assistant = deployments.accounts.users[1]; + const agent = deployments.accounts.users[1]; const receiver = deployments.accounts.users[2]; const balance0 = await contractManager.sideLedgerContract.tokenBalanceOf(provider.address); const balance1 = await contractManager.sideLedgerContract.pointBalanceOf(receiver.address); const pointAmount = Amount.make(10, 18).value; const tokenAmount = await contractManager.sideCurrencyRateContract.convertPointToToken(pointAmount); - const nonce = await contractManager.sideLedgerContract.nonceOf(assistant.address); + const nonce = await contractManager.sideLedgerContract.nonceOf(agent.address); const message = ContractUtils.getProvidePointToAddressMessage( provider.address, receiver.address, @@ -279,7 +279,7 @@ describe("Test of LoyaltyProvider", function () { nonce, contractManager.sideChainId ); - const signature = await ContractUtils.signMessage(assistant, message); + const signature = await ContractUtils.signMessage(agent, message); const response = await client.post(URI(serverURL).directory("/v1/provider/send/account").toString(), { provider: provider.address, receiver: receiver.address, @@ -303,12 +303,12 @@ describe("Test of LoyaltyProvider", function () { const phoneNumber = "+82 10-1000-9000"; const phoneHash = ContractUtils.getPhoneHash(phoneNumber); const provider = deployments.accounts.users[0]; - const assistant = deployments.accounts.users[1]; + const agent = deployments.accounts.users[1]; const balance0 = await contractManager.sideLedgerContract.tokenBalanceOf(provider.address); const balance1 = await contractManager.sideLedgerContract.unPayablePointBalanceOf(phoneHash); const pointAmount = Amount.make(10, 18).value; const tokenAmount = await contractManager.sideCurrencyRateContract.convertPointToToken(pointAmount); - const nonce = await contractManager.sideLedgerContract.nonceOf(assistant.address); + const nonce = await contractManager.sideLedgerContract.nonceOf(agent.address); const message = ContractUtils.getProvidePointToPhoneMessage( provider.address, phoneHash, @@ -316,7 +316,7 @@ describe("Test of LoyaltyProvider", function () { nonce, contractManager.sideChainId ); - const signature = await ContractUtils.signMessage(assistant, message); + const signature = await ContractUtils.signMessage(agent, message); const response = await client.post(URI(serverURL).directory("/v1/provider/send/phoneHash").toString(), { provider: provider.address, receiver: phoneHash, diff --git a/packages/relay/tspec/07_Summary.ts b/packages/relay/tspec/07_Summary.ts index 0b414e42..ba8a85c4 100644 --- a/packages/relay/tspec/07_Summary.ts +++ b/packages/relay/tspec/07_Summary.ts @@ -80,7 +80,7 @@ export type Summary1ApiSpec = Tspec.DefineApiSpec<{ * Technical representatives to provide point * @example "0x0000000000000000000000000000000000000000" */ - assistant: string; + agent: string; }; ledger: { point: { diff --git a/packages/relay/tspec/10_Provider.ts b/packages/relay/tspec/10_Provider.ts index 5d436b73..7a11cb8e 100644 --- a/packages/relay/tspec/10_Provider.ts +++ b/packages/relay/tspec/10_Provider.ts @@ -4,9 +4,9 @@ import { ResultCode } from "./types"; export type ProviderApiSpec = Tspec.DefineApiSpec<{ tags: ["Loyalty Point Provider"]; paths: { - "/v1/provider/assistant/{provider}": { + "/v1/provider/agent/{provider}": { get: { - summary: "Provides the assistant's information"; + summary: "Provides the agent's information"; path: { /** * Wallet address of the provider @@ -28,15 +28,10 @@ export type ProviderApiSpec = Tspec.DefineApiSpec<{ */ provider: string; /** - * Wallet address of the assistant + * Wallet address of the agent * @example "0x3FE8D00143bd0eAd2397D48ba0E31E5E1268dBfb" */ - assistant: string; - /** - * Hash of transaction - * @example "0xe5502185d39057bd82e6dde675821b87313570df77d3e23d8e5712bd5f3fa6b6" - */ - txHash: string; + agent: string; }; error?: { /** @@ -49,9 +44,9 @@ export type ProviderApiSpec = Tspec.DefineApiSpec<{ }; }; }; - "/v1/provider/assistant/register": { + "/v1/provider/agent/register": { post: { - summary: "Register the provider's assistant. The assistant can only process the instructions of the point transfer"; + summary: "Register the provider's agent. The agent can only process the instructions of the point transfer"; body: { /** * Wallet address of the provider @@ -59,12 +54,12 @@ export type ProviderApiSpec = Tspec.DefineApiSpec<{ */ provider: string; /** - * Wallet address of the assistant + * Wallet address of the agent * @example "0x3FE8D00143bd0eAd2397D48ba0E31E5E1268dBfb" */ - assistant: string; + agent: string; /** - * Signature of provider or assistant + * Signature of provider or agent * @example "0x020d671b80fbd20466d8cb65cef79a24e3bca3fdf82e9dd89d78e7a4c4c045bd72944c20bb1d839e76ee6bb69fed61f64376c37799598b40b8c49148f3cdd88a1b" */ signature: string; @@ -83,10 +78,15 @@ export type ProviderApiSpec = Tspec.DefineApiSpec<{ */ provider: string; /** - * Wallet address of the assistant + * Wallet address of the agent * @example "0x3FE8D00143bd0eAd2397D48ba0E31E5E1268dBfb" */ - assistant: string; + agent: string; + /** + * Hash of transaction + * @example "0xe5502185d39057bd82e6dde675821b87313570df77d3e23d8e5712bd5f3fa6b6" + */ + txHash: string; }; error?: { /** @@ -206,7 +206,7 @@ export type ProviderApiSpec = Tspec.DefineApiSpec<{ */ amount: string; /** - * Signature of provider or assistant + * Signature of provider or agent * @example "0x020d671b80fbd20466d8cb65cef79a24e3bca3fdf82e9dd89d78e7a4c4c045bd72944c20bb1d839e76ee6bb69fed61f64376c37799598b40b8c49148f3cdd88a1b" */ signature: string; @@ -271,7 +271,7 @@ export type ProviderApiSpec = Tspec.DefineApiSpec<{ */ amount: string; /** - * Signature of provider or assistant + * Signature of provider or agent * @example "0x020d671b80fbd20466d8cb65cef79a24e3bca3fdf82e9dd89d78e7a4c4c045bd72944c20bb1d839e76ee6bb69fed61f64376c37799598b40b8c49148f3cdd88a1b" */ signature: string;