From b51ba8b14fb46c74158dd8d555a5545a25dafe5a Mon Sep 17 00:00:00 2001 From: rs-work-OL <65215644+rs-work-OL@users.noreply.github.com> Date: Fri, 3 Feb 2023 10:51:24 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=E3=82=B9=E3=83=9A=E3=83=AB=E3=83=9F?= =?UTF-8?q?=E3=82=B9=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/AnnounceCreateApostille.ts | 2 +- examples/AnnounceUpdateApostille.ts | 2 +- examples/ApostilleAssignOwners.ts | 2 +- examples/ApostilleWithMetadata.ts | 8 ++--- src/model/ApostilleTransaction.ts | 52 ++++++++++++++--------------- src/service/AuditService.ts | 4 +-- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/examples/AnnounceCreateApostille.ts b/examples/AnnounceCreateApostille.ts index f55da18..6794b66 100644 --- a/examples/AnnounceCreateApostille.ts +++ b/examples/AnnounceCreateApostille.ts @@ -41,7 +41,7 @@ async function announceApostilleTx() { apiEndpoint, epochAdjustment ); - const announceInfo = await apostilleTx.singedTransactionAndAnnounceType(); + const announceInfo = await apostilleTx.signedTransactionAndAnnounceType(); const transactionRepo = repoFactory.createTransactionRepository(); const receiptRepo = repoFactory.createReceiptRepository(); const transactionService = new TransactionService(transactionRepo, receiptRepo); diff --git a/examples/AnnounceUpdateApostille.ts b/examples/AnnounceUpdateApostille.ts index 0c6e865..66cacac 100644 --- a/examples/AnnounceUpdateApostille.ts +++ b/examples/AnnounceUpdateApostille.ts @@ -43,7 +43,7 @@ async function announceUpdateApostilleTx() { epochAdjustment ); - const announceInfo = await apostilleTx.singedTransactionAndAnnounceType(); + const announceInfo = await apostilleTx.signedTransactionAndAnnounceType(); const transactionRepo = repoFactory.createTransactionRepository(); const receiptRepo = repoFactory.createReceiptRepository(); const transactionService = new TransactionService( diff --git a/examples/ApostilleAssignOwners.ts b/examples/ApostilleAssignOwners.ts index 675ea55..fee460b 100644 --- a/examples/ApostilleAssignOwners.ts +++ b/examples/ApostilleAssignOwners.ts @@ -56,7 +56,7 @@ async function announceApostilleTx() { option ); - apostilleTx.singedTransactionAndAnnounceType().then((info) => { + apostilleTx.signedTransactionAndAnnounceType().then((info) => { const signedTx = info.signedTransaction; const hashLockTx = HashLockTransaction.create( Deadline.create(epochAdjustment), diff --git a/examples/ApostilleWithMetadata.ts b/examples/ApostilleWithMetadata.ts index db11c18..16d61cb 100644 --- a/examples/ApostilleWithMetadata.ts +++ b/examples/ApostilleWithMetadata.ts @@ -6,7 +6,7 @@ import { HashingType } from '../src/utils/hash'; const data = 'Hello World'; const seed = `hello_${new Date().toLocaleString()}.txt`; -const singerKey = '__INPUT_YOUR_PRIVATE_KEY__'; +const signerKey = '__INPUT_YOUR_PRIVATE_KEY__'; const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; @@ -40,12 +40,12 @@ const option: IApostilleOptions = { } async function announceApostilleTx() { - const singer = Account.createFromPrivateKey(singerKey, networkType); + const signer = Account.createFromPrivateKey(signerKey, networkType); const apostilleTransaction = ApostilleTransaction.createFromData( data, HashingType.Type.sha256, seed, - singer, + signer, networkType, generationHash, feeMultiplier, @@ -54,7 +54,7 @@ async function announceApostilleTx() { option ); - apostilleTransaction.singedTransactionAndAnnounceType().then((info) => { + apostilleTransaction.signedTransactionAndAnnounceType().then((info) => { const signedTx = info.signedTransaction; const transactionService = new TransactionService( repoFactory.createTransactionRepository(), diff --git a/src/model/ApostilleTransaction.ts b/src/model/ApostilleTransaction.ts index e4802ef..57f4cbc 100644 --- a/src/model/ApostilleTransaction.ts +++ b/src/model/ApostilleTransaction.ts @@ -9,9 +9,9 @@ import { AnnounceInfo } from "./AnnounceInfo"; export enum AnnounceType { CompleteWithApostilleAccountSign, - CompleteWithoutApostilleAccountSing, - BondedWithApostilleAccountSing, - BondedWithoutApostilleAccountSing, + CompleteWithoutApostilleAccountSign, + BondedWithApostilleAccountSign, + BondedWithoutApostilleAccountSign, CannotAnnounce, Unknown, } @@ -30,7 +30,7 @@ export class ApostilleTransaction { * @param data * @param hashingType * @param seed - * @param singerAccount + * @param signerAccount * @param networkType * @param generationHashSeed * @param feeMultiplier @@ -41,7 +41,7 @@ export class ApostilleTransaction { data: DataView, hashingType: HashingType.Type, seed: string, - singerAccount: Account, + signerAccount: Account, networkType: NetworkType, generationHashSeed: string, feeMultiplier: number, @@ -50,12 +50,12 @@ export class ApostilleTransaction { options?: IApostilleOptions, ) { const hashFunc = HashFunctionCreator.create(hashingType); - const apostilleMessage = hashFunc.createApostilleTransactionMessage(data, singerAccount); + const apostilleMessage = hashFunc.createApostilleTransactionMessage(data, signerAccount); const apostilleAccount = ApostilleAccount.create(seed, - singerAccount, + signerAccount, apiEndpoint); const apostilleTransaction = new ApostilleTransaction( - singerAccount, + signerAccount, apostilleAccount, apostilleMessage, networkType, @@ -208,7 +208,7 @@ export class ApostilleTransaction { /** * */ - public async singedTransactionAndAnnounceType() { + public async signedTransactionAndAnnounceType() { const innerTxs = this.convertInnerTransactions(); const aggregateTx = await this.createAggregateTransaction(innerTxs); const signedTx = this.signTransaction(aggregateTx); @@ -222,8 +222,8 @@ export class ApostilleTransaction { private shouldUseHashLockTransaction() { switch(this.announceType) { - case AnnounceType.BondedWithApostilleAccountSing: - case AnnounceType.BondedWithoutApostilleAccountSing: + case AnnounceType.BondedWithApostilleAccountSign: + case AnnounceType.BondedWithoutApostilleAccountSign: return true; default: return false; @@ -302,10 +302,10 @@ export class ApostilleTransaction { await this.setAnnounceType(); switch(this.announceType) { case AnnounceType.CompleteWithApostilleAccountSign: - case AnnounceType.CompleteWithoutApostilleAccountSing: + case AnnounceType.CompleteWithoutApostilleAccountSign: return this.createCompleteTransaction(innerTxs); - case AnnounceType.BondedWithApostilleAccountSing: - case AnnounceType.BondedWithoutApostilleAccountSing: + case AnnounceType.BondedWithApostilleAccountSign: + case AnnounceType.BondedWithoutApostilleAccountSign: return this.createBondedTransaction(innerTxs); default: throw Error('Can not create aggregate transaction'); @@ -324,23 +324,23 @@ export class ApostilleTransaction { } private createBondedTransaction(innerTxs: InnerTransaction[]) { - const singerCount = this.getSignerCount(); + const signerCount = this.getSignerCount(); const tx = AggregateTransaction.createBonded( Deadline.create(this.epochAdjustment), innerTxs, this.networkType, [] - ).setMaxFeeForAggregate(this.feeMultiplier, singerCount); + ).setMaxFeeForAggregate(this.feeMultiplier, signerCount); return tx; } private signTransaction(aggregateTx: AggregateTransaction) { switch(this.announceType) { case AnnounceType.CompleteWithApostilleAccountSign: - case AnnounceType.BondedWithApostilleAccountSing: + case AnnounceType.BondedWithApostilleAccountSign: return this.signTransactionWithApostilleAccount(aggregateTx) - case AnnounceType.CompleteWithoutApostilleAccountSing: - case AnnounceType.BondedWithoutApostilleAccountSing: + case AnnounceType.CompleteWithoutApostilleAccountSign: + case AnnounceType.BondedWithoutApostilleAccountSign: return this.signTransactionWithoutApostilleAccount(aggregateTx); default: throw Error('Can not sign transaction'); @@ -368,17 +368,17 @@ export class ApostilleTransaction { } private getSignerCount() { - if (this.announceType === AnnounceType.CompleteWithoutApostilleAccountSing) { + if (this.announceType === AnnounceType.CompleteWithoutApostilleAccountSign) { return 1; } if (this.announceType === AnnounceType.CompleteWithApostilleAccountSign) { return 2; } - if (this.announceType === AnnounceType.BondedWithApostilleAccountSing && + if (this.announceType === AnnounceType.BondedWithApostilleAccountSign && this.options && this.options.assignOwners) { return 2 + this.options.assignOwners.length; } - if (this.announceType === AnnounceType.BondedWithoutApostilleAccountSing) { + if (this.announceType === AnnounceType.BondedWithoutApostilleAccountSign) { return this.apostilleAccount.multisigInfo!.minApproval; } throw Error('Can not announce transaction'); @@ -389,12 +389,12 @@ export class ApostilleTransaction { if (this.apostilleAccount.multisigInfo) { const {multisigInfo} = this.apostilleAccount; if (multisigInfo.minApproval >= 2) { - this.announceType = AnnounceType.BondedWithoutApostilleAccountSing; + this.announceType = AnnounceType.BondedWithoutApostilleAccountSign; return; } if (multisigInfo.minApproval === 1 && multisigInfo.hasCosigner(this.signerAccount.address)) { - this.announceType = AnnounceType.CompleteWithoutApostilleAccountSing; + this.announceType = AnnounceType.CompleteWithoutApostilleAccountSign; return; } if (multisigInfo.minApproval === 1 && @@ -409,13 +409,13 @@ export class ApostilleTransaction { this.announceType = AnnounceType.CompleteWithApostilleAccountSign; return; } - this.announceType = AnnounceType.BondedWithApostilleAccountSing; + this.announceType = AnnounceType.BondedWithApostilleAccountSign; return; } if (this.metaDataTransactions) { this.announceType = AnnounceType.CompleteWithApostilleAccountSign; return; } - this.announceType = AnnounceType.CompleteWithoutApostilleAccountSing; + this.announceType = AnnounceType.CompleteWithoutApostilleAccountSign; } } diff --git a/src/service/AuditService.ts b/src/service/AuditService.ts index 1a79e02..717bcf1 100644 --- a/src/service/AuditService.ts +++ b/src/service/AuditService.ts @@ -53,11 +53,11 @@ export class AuditService { private async auditWithConfirmed() { const coreTx = await this.getTransaction(); - const singerPublicAccount = coreTx.signer!; + const signerPublicAccount = coreTx.signer!; const parsedMessage = this.parseMessage(coreTx.message.payload); const hashFunction = HashFunctionCreator.createWithTypeStr(parsedMessage.hashingTypeStr); const hashedData = hashFunction.hashing(this.data); - const isValid = singerPublicAccount.verifySignature(hashedData, parsedMessage.signedHash); + const isValid = signerPublicAccount.verifySignature(hashedData, parsedMessage.signedHash); if (isValid) { const signer = coreTx.signer!.address; const apostilleAccount = coreTx.recipientAddress as Address; From 15dc958a062039a340b09875d48b5dd732dc3164 Mon Sep 17 00:00:00 2001 From: rs-work-OL <65215644+rs-work-OL@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:25:48 +0900 Subject: [PATCH 2/7] =?UTF-8?q?rxjs=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/AnnounceCreateApostille.ts | 26 +++++++++++++++----------- examples/AnnounceUpdateApostille.ts | 24 ++++++++++++++---------- examples/ApostilleAssignOwners.ts | 24 ++++++++++++++---------- examples/ApostilleWithMetadata.ts | 27 +++++++++++++++------------ package.json | 2 +- src/model/ApostilleAccount.ts | 3 ++- src/service/AuditService.ts | 11 ++++++----- 7 files changed, 67 insertions(+), 50 deletions(-) diff --git a/examples/AnnounceCreateApostille.ts b/examples/AnnounceCreateApostille.ts index 6794b66..2baf3cf 100644 --- a/examples/AnnounceCreateApostille.ts +++ b/examples/AnnounceCreateApostille.ts @@ -1,4 +1,5 @@ /* eslint-disable no-console */ +import { lastValueFrom } from 'rxjs'; import { Account, RepositoryFactoryHttp, TransactionService } from 'symbol-sdk'; import { ApostilleTransaction } from '../src/model'; import { HashingType } from '../src/utils/hash'; @@ -17,14 +18,14 @@ let feeMultiplier = 0; const repoFactory = new RepositoryFactoryHttp(apiEndpoint); async function getNetworkProps() { - generationHash = await repoFactory.getGenerationHash().toPromise(); - networkType = await repoFactory.getNetworkType().toPromise(); - epochAdjustment = await repoFactory.getEpochAdjustment().toPromise(); + generationHash = await lastValueFrom(repoFactory.getGenerationHash()); + networkType = await lastValueFrom(repoFactory.getNetworkType()); + epochAdjustment = await lastValueFrom(repoFactory.getEpochAdjustment()); } async function getFeeMultiplier() { const networkRepo = await repoFactory.createNetworkRepository(); - const feeMultipliers = await networkRepo.getTransactionFees().toPromise(); + const feeMultipliers = await lastValueFrom(networkRepo.getTransactionFees()); feeMultiplier = feeMultipliers.minFeeMultiplier; } @@ -48,13 +49,16 @@ async function announceApostilleTx() { const listener = repoFactory.createListener(); listener.open().then(() => { - transactionService.announce(announceInfo.signedTransaction, listener).subscribe((x) => { - console.log(`txHash: ${x.transactionInfo?.hash}`); - console.log(`apostille owner key: ${apostilleTx.apostilleAccount.account?.privateKey}`); - listener.close(); - }, (err) => { - console.error(err); - listener.close(); + transactionService.announce(announceInfo.signedTransaction, listener).subscribe({ + next(x) { + console.log(`txHash: ${x.transactionInfo?.hash}`); + console.log(`apostille owner key: ${apostilleTx.apostilleAccount.account?.privateKey}`); + listener.close(); + }, + error(err) { + console.error(err); + listener.close(); + } }); }); } diff --git a/examples/AnnounceUpdateApostille.ts b/examples/AnnounceUpdateApostille.ts index 66cacac..e137833 100644 --- a/examples/AnnounceUpdateApostille.ts +++ b/examples/AnnounceUpdateApostille.ts @@ -1,4 +1,5 @@ /* eslint-disable no-console */ +import { lastValueFrom } from "rxjs"; import { Account, RepositoryFactoryHttp, TransactionService } from "symbol-sdk"; import { ApostilleTransaction } from "../src/model"; import { HashingType } from "../src/utils/hash"; @@ -16,14 +17,14 @@ let feeMultiplier = 0; const repoFactory = new RepositoryFactoryHttp(apiEndpoint); async function getNetworkProps() { - generationHash = await repoFactory.getGenerationHash().toPromise(); - networkType = await repoFactory.getNetworkType().toPromise(); - epochAdjustment = await repoFactory.getEpochAdjustment().toPromise(); + generationHash = await lastValueFrom(repoFactory.getGenerationHash()); + networkType = await lastValueFrom(repoFactory.getNetworkType()); + epochAdjustment = await lastValueFrom(repoFactory.getEpochAdjustment()); } async function getFeeMultiplier() { const networkRepo = await repoFactory.createNetworkRepository(); - const feeMultipliers = await networkRepo.getTransactionFees().toPromise(); + const feeMultipliers = await lastValueFrom(networkRepo.getTransactionFees()); feeMultiplier = feeMultipliers.minFeeMultiplier; } @@ -53,12 +54,15 @@ async function announceUpdateApostilleTx() { const listener = repoFactory.createListener(); listener.open().then(() => { - transactionService.announce(announceInfo.signedTransaction, listener).subscribe((x) => { - console.log(`txHash: ${x.transactionInfo?.hash}`); - listener.close(); - }, (err) => { - console.error(err); - listener.close(); + transactionService.announce(announceInfo.signedTransaction, listener).subscribe({ + next(x) { + console.log(`txHash: ${x.transactionInfo?.hash}`); + listener.close(); + }, + error(err) { + console.error(err); + listener.close(); + } }) }) } diff --git a/examples/ApostilleAssignOwners.ts b/examples/ApostilleAssignOwners.ts index fee460b..4dc6083 100644 --- a/examples/ApostilleAssignOwners.ts +++ b/examples/ApostilleAssignOwners.ts @@ -1,4 +1,5 @@ /* eslint-disable no-console */ +import { lastValueFrom } from 'rxjs'; import { Account, RepositoryFactoryHttp, Address, HashLockTransaction, Deadline, UInt64, TransactionService, Currency } from 'symbol-sdk'; import { IApostilleOptions, ApostilleTransaction } from '../src/model'; import { HashingType } from '../src/utils/hash'; @@ -17,14 +18,14 @@ let feeMultiplier = 0; const repoFactory = new RepositoryFactoryHttp(apiEndpoint); async function getNetworkProps() { - generationHash = await repoFactory.getGenerationHash().toPromise(); - networkType = await repoFactory.getNetworkType().toPromise(); - epochAdjustment = await repoFactory.getEpochAdjustment().toPromise(); + generationHash = await lastValueFrom(repoFactory.getGenerationHash()); + networkType = await lastValueFrom(repoFactory.getNetworkType()); + epochAdjustment = await lastValueFrom(repoFactory.getEpochAdjustment()); } async function getFeeMultiplier() { const networkRepo = await repoFactory.createNetworkRepository(); - const feeMultipliers = await networkRepo.getTransactionFees().toPromise(); + const feeMultipliers = await lastValueFrom(networkRepo.getTransactionFees()); feeMultiplier = feeMultipliers.minFeeMultiplier; } @@ -78,12 +79,15 @@ async function announceApostilleTx() { signedHashLockTx, signedTx, listener - ).subscribe((x) => { - listener.close(); - console.log(x); - }, (err) => { - listener.close(); - console.error(err); + ).subscribe({ + next(x) { + listener.close(); + console.log(x); + }, + error(err) { + listener.close(); + console.error(err); + } }); }); }); diff --git a/examples/ApostilleWithMetadata.ts b/examples/ApostilleWithMetadata.ts index 16d61cb..52ded42 100644 --- a/examples/ApostilleWithMetadata.ts +++ b/examples/ApostilleWithMetadata.ts @@ -1,4 +1,5 @@ /* eslint-disable no-console */ +import { lastValueFrom } from 'rxjs'; import { Account, RepositoryFactoryHttp, TransactionService } from 'symbol-sdk'; import { IApostilleMetadata, IApostilleOptions, ApostilleTransaction } from '../src/model'; import { HashingType } from '../src/utils/hash'; @@ -18,14 +19,14 @@ let epochAdjustment = 0; const repoFactory = new RepositoryFactoryHttp(apiEndpoint); async function getNetworkProps() { - generationHash = await repoFactory.getGenerationHash().toPromise(); - networkType = await repoFactory.getNetworkType().toPromise(); - epochAdjustment = await repoFactory.getEpochAdjustment().toPromise(); + generationHash = await lastValueFrom(repoFactory.getGenerationHash()); + networkType = await lastValueFrom(repoFactory.getNetworkType()); + epochAdjustment = await lastValueFrom(repoFactory.getEpochAdjustment()); } async function getFeeMultiplier() { const networkRepo = await repoFactory.createNetworkRepository(); - const feeMultipliers = await networkRepo.getTransactionFees().toPromise(); + const feeMultipliers = await lastValueFrom(networkRepo.getTransactionFees()); feeMultiplier = feeMultipliers.minFeeMultiplier; } @@ -62,14 +63,16 @@ async function announceApostilleTx() { ); const listener = repoFactory.createListener(); listener.open().then(() => { - transactionService.announce(signedTx, listener).subscribe((x) => { - console.log('--- Apostille created ---'); - console.log(`txHash: ${x.transactionInfo!.hash}`); - console.log(`apostille owner key: ${apostilleTransaction.apostilleAccount.account!.privateKey}`); - listener.close(); - }, (err) => { - console.error(err); - listener.close(); + transactionService.announce(signedTx, listener).subscribe({ + next(x) { + console.log('--- Apostille created ---'); + console.log(`txHash: ${x.transactionInfo!.hash}`); + console.log(`apostille owner key: ${apostilleTransaction.apostilleAccount.account!.privateKey}`); + listener.close(); + }, + error(err) { + console.error(err);listener.close(); + } }); }).catch((err) => { console.error(err); diff --git a/package.json b/package.json index 8f877d7..ee83e29 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "js-sha1": "^0.6.0", "js-sha256": "^0.9.0", "js-sha3": "^0.8.0", - "rxjs": "^6.5.3", "symbol-sdk": "^1.0.3", + "rxjs": "^7.8.0", "utf8": "^3.0.0" }, "devDependencies": { diff --git a/src/model/ApostilleAccount.ts b/src/model/ApostilleAccount.ts index 5ddbb26..4b40a2b 100644 --- a/src/model/ApostilleAccount.ts +++ b/src/model/ApostilleAccount.ts @@ -1,5 +1,6 @@ import { PublicAccount, Account, MultisigHttp, MultisigAccountInfo } from 'symbol-sdk'; import { createHash } from 'crypto'; +import { lastValueFrom } from 'rxjs'; const fixPrivateKey = (privateKey) => { return (`0000000000000000000000000000000000000000000000000000000000000000${privateKey.replace(/^00/, '')}`) @@ -44,7 +45,7 @@ export class ApostilleAccount { if (this.apiEndpoint) { try { const multisigHttp = new MultisigHttp(this.apiEndpoint); - const multisigInfo = await multisigHttp.getMultisigAccountInfo(this.publicAccount.address).toPromise(); + const multisigInfo = await lastValueFrom(multisigHttp.getMultisigAccountInfo(this.publicAccount.address)); this.multisigInfo = multisigInfo; } catch(err) { if (err.message) { diff --git a/src/service/AuditService.ts b/src/service/AuditService.ts index 717bcf1..8bb1e4c 100644 --- a/src/service/AuditService.ts +++ b/src/service/AuditService.ts @@ -1,3 +1,4 @@ +import { lastValueFrom } from "rxjs"; import { RepositoryFactoryHttp, TransactionGroup, AggregateTransaction, TransferTransaction, UInt64, BlockInfo, Address, MultisigAccountModificationTransaction, TransactionStatusHttp } from "symbol-sdk"; import { IAuditResult, IPartialTxAuditResult, AuditType, IApostilleTxMessage } from "../model"; import { HashFunctionCreator, DataView } from "../utils/hash"; @@ -11,7 +12,7 @@ export class AuditService { apiEndpoint: string, ) { const transactionStatusHttp = new TransactionStatusHttp(apiEndpoint); - const status = await transactionStatusHttp.getTransactionStatus(txHash).toPromise(); + const status = await lastValueFrom(transactionStatusHttp.getTransactionStatus(txHash)); if (status.group === 'confirmed') { const result = await this.auditWithComplete(data, txHash, apiEndpoint); return result; @@ -107,14 +108,14 @@ export class AuditService { private async getTimestamp(blockHight: UInt64) { const blockRep = this.repositoryFactory.createBlockRepository(); - const blockInfo: BlockInfo = await blockRep.getBlockByHeight(blockHight).toPromise(); + const blockInfo: BlockInfo = await lastValueFrom(blockRep.getBlockByHeight(blockHight)); const t = Number(blockInfo.timestamp.toString()); const epochAdjustment = await this.getEpochAdjustment(); return new Date(t + epochAdjustment * 1000); } private async getEpochAdjustment() { - const epochAdjustment = await this.repositoryFactory.getEpochAdjustment().toPromise(); + const epochAdjustment = await lastValueFrom(this.repositoryFactory.getEpochAdjustment()); return epochAdjustment; } @@ -133,7 +134,7 @@ export class AuditService { private async getTransaction() { const transactionRep = this.repositoryFactory.createTransactionRepository(); - const tx = await transactionRep.getTransaction(this.txHash, TransactionGroup.Confirmed).toPromise(); + const tx = await lastValueFrom(transactionRep.getTransaction(this.txHash, TransactionGroup.Confirmed)); if (tx instanceof AggregateTransaction) { const coreInnerTx = tx.innerTransactions.find(t => t instanceof TransferTransaction && t.message.payload.startsWith('fe4e5459')); if (coreInnerTx) { @@ -147,7 +148,7 @@ export class AuditService { private async getTransactionFromPartial() { const transactionRep = this.repositoryFactory.createTransactionRepository(); - const tx = await transactionRep.getTransaction(this.txHash, TransactionGroup.Partial).toPromise(); + const tx = await lastValueFrom(transactionRep.getTransaction(this.txHash, TransactionGroup.Partial)); if (tx instanceof AggregateTransaction) { const coreInnerTx = tx.innerTransactions.find(t => t instanceof TransferTransaction && t.message.payload.startsWith('fe4e5459')); if (coreInnerTx) { From 38903623d61ff8337f315812471dfdef1c225731 Mon Sep 17 00:00:00 2001 From: rs-work-OL <65215644+rs-work-OL@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:28:56 +0900 Subject: [PATCH 3/7] =?UTF-8?q?symbol-sdk=E3=83=90=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/model/ApostilleTransaction.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ee83e29..33e6237 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "js-sha1": "^0.6.0", "js-sha256": "^0.9.0", "js-sha3": "^0.8.0", - "symbol-sdk": "^1.0.3", "rxjs": "^7.8.0", + "symbol-sdk": "^2.0.3", "utf8": "^3.0.0" }, "devDependencies": { diff --git a/src/model/ApostilleTransaction.ts b/src/model/ApostilleTransaction.ts index 57f4cbc..8323d48 100644 --- a/src/model/ApostilleTransaction.ts +++ b/src/model/ApostilleTransaction.ts @@ -269,8 +269,8 @@ export class ApostilleTransaction { Deadline.create(this.epochAdjustment), this.apostilleAccount.publicAccount.address, MetadataKeyHelper.keyToKeyId(k), - Convert.utf8ToHex(v).length, - Convert.utf8ToHex(v), + Convert.utf8ToUint8(v).byteLength, + Convert.utf8ToUint8(v), this.networkType ); txs.push(tx); From af8a7f56bec60dd57981614911b5729df799b764 Mon Sep 17 00:00:00 2001 From: rs-work-OL <65215644+rs-work-OL@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:39:10 +0900 Subject: [PATCH 4/7] =?UTF-8?q?package-lock.json=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 90 ++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15bc602..1a89715 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,20 @@ { "name": "simple-apostille-v2", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "simple-apostille-v2", - "version": "1.0.3", + "version": "1.0.4", "license": "apache-v2", "dependencies": { "js-md5": "^0.7.3", "js-sha1": "^0.6.0", "js-sha256": "^0.9.0", "js-sha3": "^0.8.0", - "rxjs": "^6.5.3", - "symbol-sdk": "^1.0.3", + "rxjs": "^7.8.0", + "symbol-sdk": "^2.0.3", "utf8": "^3.0.0" }, "devDependencies": { @@ -1573,9 +1573,9 @@ "dev": true }, "node_modules/catbuffer-typescript": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/catbuffer-typescript/-/catbuffer-typescript-1.0.1.tgz", - "integrity": "sha512-IyC2bmBEMRY96/NMsAer+qMTSa6yAwKfGIbpYPDPnlSb4UguNOlSabbCFH0CDQfhWuO6wqH97xGCuB4qY3OCwA==" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/catbuffer-typescript/-/catbuffer-typescript-1.0.2.tgz", + "integrity": "sha512-wFcpz5A9H1jqVyfaTv596V3X19b1iBfz25CPAesQjtFDVq2zY0G2HvoYldggqlkmqNbkFaz5TICkKRsWgn9dyQ==" }, "node_modules/chalk": { "version": "3.0.0", @@ -5905,20 +5905,17 @@ } }, "node_modules/rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", "dependencies": { - "tslib": "^1.9.0" - }, - "engines": { - "npm": ">=2.0.0" + "tslib": "^2.1.0" } }, - "node_modules/rxjs-compat": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/rxjs-compat/-/rxjs-compat-6.6.3.tgz", - "integrity": "sha512-y+wUqq7bS2dG+7rH2fNMoxsDiJ32RQzFxZQE/JdtpnmEZmwLQrb1tCiItyHxdXJHXjmHnnzFscn3b6PEmORGKw==" + "node_modules/rxjs/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" }, "node_modules/safe-buffer": { "version": "5.2.1", @@ -6743,12 +6740,12 @@ "integrity": "sha512-Md3/wkYLWTeJ/o99kXajW5dDs7Ok7AWfGRGDThb2bpC53KVxwnMl2ho/KUPT2Y+CeuIB62+Hgp9NtJLvgXYzHw==" }, "node_modules/symbol-sdk": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/symbol-sdk/-/symbol-sdk-1.0.3.tgz", - "integrity": "sha512-4DLOzc74Duh8kqlUJr7U4KgjxSv/KIrFU4veNKnbiMkH/P5QmWIh0IaZ6Ui+NS11fg2PAtmAh33c+0DQd4haRw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/symbol-sdk/-/symbol-sdk-2.0.3.tgz", + "integrity": "sha512-cTy1/E0yQCTMBrzCNCMMSVwgZdY0MTsw5A3vJCOyG9Dne03a/u8djEW5uB1H5c+mSul91FjP74Dey1Ay7uw8MQ==", "dependencies": { "@js-joda/core": "^3.2.0", - "catbuffer-typescript": "^1.0.1", + "catbuffer-typescript": "^1.0.2", "crypto-js": "^4.0.0", "futoin-hkdf": "^1.3.2", "js-sha256": "^0.9.0", @@ -6758,12 +6755,14 @@ "merkletreejs": "^0.2.9", "node-fetch": "^2.6.0", "ripemd160": "^2.0.2", - "rxjs": "^6.6.7", - "rxjs-compat": "^6.6.3", + "rxjs": "^7.4.0", "symbol-openapi-typescript-fetch-client": "^1.0.3", "tweetnacl": "^1.0.3", "utf8": "^2.1.2", "ws": "^7.3.1" + }, + "engines": { + "node": ">=12.22.1" } }, "node_modules/symbol-sdk/node_modules/utf8": { @@ -7043,7 +7042,8 @@ "node_modules/tslib": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" + "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", + "dev": true }, "node_modules/tsutils": { "version": "3.17.1", @@ -8822,9 +8822,9 @@ "dev": true }, "catbuffer-typescript": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/catbuffer-typescript/-/catbuffer-typescript-1.0.1.tgz", - "integrity": "sha512-IyC2bmBEMRY96/NMsAer+qMTSa6yAwKfGIbpYPDPnlSb4UguNOlSabbCFH0CDQfhWuO6wqH97xGCuB4qY3OCwA==" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/catbuffer-typescript/-/catbuffer-typescript-1.0.2.tgz", + "integrity": "sha512-wFcpz5A9H1jqVyfaTv596V3X19b1iBfz25CPAesQjtFDVq2zY0G2HvoYldggqlkmqNbkFaz5TICkKRsWgn9dyQ==" }, "chalk": { "version": "3.0.0", @@ -12310,18 +12310,20 @@ "dev": true }, "rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "version": "7.8.0", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.0.tgz", + "integrity": "sha512-F2+gxDshqmIub1KdvZkaEfGDwLNpPvk9Fs6LD/MyQxNgMds/WH9OdDDXOmxUZpME+iSK3rQCctkL0DYyytUqMg==", "requires": { - "tslib": "^1.9.0" + "tslib": "^2.1.0" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==" + } } }, - "rxjs-compat": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/rxjs-compat/-/rxjs-compat-6.6.3.tgz", - "integrity": "sha512-y+wUqq7bS2dG+7rH2fNMoxsDiJ32RQzFxZQE/JdtpnmEZmwLQrb1tCiItyHxdXJHXjmHnnzFscn3b6PEmORGKw==" - }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -13014,12 +13016,12 @@ "integrity": "sha512-Md3/wkYLWTeJ/o99kXajW5dDs7Ok7AWfGRGDThb2bpC53KVxwnMl2ho/KUPT2Y+CeuIB62+Hgp9NtJLvgXYzHw==" }, "symbol-sdk": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/symbol-sdk/-/symbol-sdk-1.0.3.tgz", - "integrity": "sha512-4DLOzc74Duh8kqlUJr7U4KgjxSv/KIrFU4veNKnbiMkH/P5QmWIh0IaZ6Ui+NS11fg2PAtmAh33c+0DQd4haRw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/symbol-sdk/-/symbol-sdk-2.0.3.tgz", + "integrity": "sha512-cTy1/E0yQCTMBrzCNCMMSVwgZdY0MTsw5A3vJCOyG9Dne03a/u8djEW5uB1H5c+mSul91FjP74Dey1Ay7uw8MQ==", "requires": { "@js-joda/core": "^3.2.0", - "catbuffer-typescript": "^1.0.1", + "catbuffer-typescript": "^1.0.2", "crypto-js": "^4.0.0", "futoin-hkdf": "^1.3.2", "js-sha256": "^0.9.0", @@ -13029,8 +13031,7 @@ "merkletreejs": "^0.2.9", "node-fetch": "^2.6.0", "ripemd160": "^2.0.2", - "rxjs": "^6.6.7", - "rxjs-compat": "^6.6.3", + "rxjs": "^7.4.0", "symbol-openapi-typescript-fetch-client": "^1.0.3", "tweetnacl": "^1.0.3", "utf8": "^2.1.2", @@ -13268,7 +13269,8 @@ "tslib": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", - "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" + "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", + "dev": true }, "tsutils": { "version": "3.17.1", From 3ff8038f90e253a1afd7f1de0b95f9c934e54acd Mon Sep 17 00:00:00 2001 From: rs-work-OL <65215644+rs-work-OL@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:42:14 +0900 Subject: [PATCH 5/7] =?UTF-8?q?examples/=20=E5=88=9D=E6=9C=9F=E5=85=A5?= =?UTF-8?q?=E5=8A=9B=E5=80=A4=E5=BE=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/AuditApostille.ts | 2 +- examples/AuditWithPartialTx.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/AuditApostille.ts b/examples/AuditApostille.ts index 365b70f..a8ee8a1 100644 --- a/examples/AuditApostille.ts +++ b/examples/AuditApostille.ts @@ -2,7 +2,7 @@ import { AuditService } from '../src/service'; const data = 'Hello World'; -const txHash = '4ADCC18B2D72D8D40922D14A03B077C7D8BEC1FEE9934FE69E54DBBC3800E342'; +const txHash = '__INPUT_AUDITED_TRANSACTION_HASH__'; const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; AuditService.audit(data, txHash, apiEndpoint).then((result) => { diff --git a/examples/AuditWithPartialTx.ts b/examples/AuditWithPartialTx.ts index 8cea6cf..a44061a 100644 --- a/examples/AuditWithPartialTx.ts +++ b/examples/AuditWithPartialTx.ts @@ -2,7 +2,7 @@ import { AuditService } from "../src/service"; const data = 'Hello World!'; -const txHash = '77CB1A251B028529C5AB07394D4DD5E769382C0E47FA4267B8694649ED75D003'; +const txHash = '__INPUT_AUDITED_TRANSACTION_HASH__'; const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; From 10da0ab257937c2ad3d02582caf4479a669b4295 Mon Sep 17 00:00:00 2001 From: rs-work-OL <65215644+rs-work-OL@users.noreply.github.com> Date: Fri, 3 Feb 2023 17:44:25 +0900 Subject: [PATCH 6/7] =?UTF-8?q?examples/=20=E3=83=8E=E3=83=BC=E3=83=89?= =?UTF-8?q?=E5=90=91=E3=81=91=E5=85=88=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/AnnounceCreateApostille.ts | 2 +- examples/AnnounceUpdateApostille.ts | 2 +- examples/ApostilleAssignOwners.ts | 2 +- examples/ApostilleWithMetadata.ts | 2 +- examples/AuditApostille.ts | 2 +- examples/AuditWithPartialTx.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/AnnounceCreateApostille.ts b/examples/AnnounceCreateApostille.ts index 2baf3cf..a1f52d3 100644 --- a/examples/AnnounceCreateApostille.ts +++ b/examples/AnnounceCreateApostille.ts @@ -9,7 +9,7 @@ const seed = `hello_${new Date().toLocaleString()}.txt`; const signerKey = '__INPUT_YOUR_PRIVATE_KEY__'; -const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; +const apiEndpoint = 'http://sym-test-01.opening-line.jp:3000'; let networkType = 0; let generationHash = '' let epochAdjustment = 0; diff --git a/examples/AnnounceUpdateApostille.ts b/examples/AnnounceUpdateApostille.ts index e137833..c40958f 100644 --- a/examples/AnnounceUpdateApostille.ts +++ b/examples/AnnounceUpdateApostille.ts @@ -7,7 +7,7 @@ import { HashingType } from "../src/utils/hash"; const data = 'Hello World!!'; const signerKey = '__INPUT_YOUR_PRIVATE_KEY__'; const apostilleAccountKey = '__INPUT_YOUR_APOSTILLE_ACCOUNT_PRIVATE_KEY__'; -const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; +const apiEndpoint = 'http://sym-test-01.opening-line.jp:3000'; let networkType = 0; let generationHash = '' diff --git a/examples/ApostilleAssignOwners.ts b/examples/ApostilleAssignOwners.ts index 4dc6083..4388181 100644 --- a/examples/ApostilleAssignOwners.ts +++ b/examples/ApostilleAssignOwners.ts @@ -9,7 +9,7 @@ const seed = `hello_${new Date().toLocaleString()}.txt`; const signerKey = '__INPUT_YOUR_PRIVATE_KEY__'; -const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; +const apiEndpoint = 'http://sym-test-01.opening-line.jp:3000'; let networkType = 0; let generationHash = '' let epochAdjustment = 0; diff --git a/examples/ApostilleWithMetadata.ts b/examples/ApostilleWithMetadata.ts index 52ded42..4b0727e 100644 --- a/examples/ApostilleWithMetadata.ts +++ b/examples/ApostilleWithMetadata.ts @@ -9,7 +9,7 @@ const seed = `hello_${new Date().toLocaleString()}.txt`; const signerKey = '__INPUT_YOUR_PRIVATE_KEY__'; -const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; +const apiEndpoint = 'http://sym-test-01.opening-line.jp:3000'; let networkType = 0; let generationHash = ''; diff --git a/examples/AuditApostille.ts b/examples/AuditApostille.ts index a8ee8a1..38cb4be 100644 --- a/examples/AuditApostille.ts +++ b/examples/AuditApostille.ts @@ -3,7 +3,7 @@ import { AuditService } from '../src/service'; const data = 'Hello World'; const txHash = '__INPUT_AUDITED_TRANSACTION_HASH__'; -const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; +const apiEndpoint = 'http://sym-test-01.opening-line.jp:3000'; AuditService.audit(data, txHash, apiEndpoint).then((result) => { console.log(result); diff --git a/examples/AuditWithPartialTx.ts b/examples/AuditWithPartialTx.ts index a44061a..8d22284 100644 --- a/examples/AuditWithPartialTx.ts +++ b/examples/AuditWithPartialTx.ts @@ -4,7 +4,7 @@ import { AuditService } from "../src/service"; const data = 'Hello World!'; const txHash = '__INPUT_AUDITED_TRANSACTION_HASH__'; -const apiEndpoint = 'https://sym-test.opening-line.jp:3001'; +const apiEndpoint = 'http://sym-test-01.opening-line.jp:3000'; AuditService.audit(data, txHash, apiEndpoint).then((result) => { console.log(result); From ef7e23c6a82a8ea4897d11e26e93d9aaacc636ba Mon Sep 17 00:00:00 2001 From: rs-work-OL <65215644+rs-work-OL@users.noreply.github.com> Date: Mon, 6 Feb 2023 11:34:33 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E6=95=B4?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/ApostilleWithMetadata.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/ApostilleWithMetadata.ts b/examples/ApostilleWithMetadata.ts index 4b0727e..c34d539 100644 --- a/examples/ApostilleWithMetadata.ts +++ b/examples/ApostilleWithMetadata.ts @@ -71,7 +71,8 @@ async function announceApostilleTx() { listener.close(); }, error(err) { - console.error(err);listener.close(); + console.error(err); + listener.close(); } }); }).catch((err) => {