opensphere-inc / metal-on-symbol Goto Github PK
View Code? Open in Web Editor NEWMetal on Symbol
License: MIT License
Metal on Symbol
License: MIT License
MetalService が Buffer を使っているので、Uint8Array と適当な base64 トランスコーダに置き換え、よりブラウザフレンドリーにします。
現在ペイロードが base64 にエンコードされているが、Metadata の値はバイナリも対応しているので、次のバージョンアップでバイナリ表現をサポートする。
尚、デコーダは従来の base64 にも引き続き対応すること。
(チャンクヘッダのバージョンで対応予定)
以下のような手順でexecuteしましたが、うまくforgeできませんでした。
metal = require("/node_modules/metal-on-symbol");
metal.SymbolService.init({ node_url: "https://mikun-testnet.tk:3001" ,repo_factory_config:{websocketUrl:"wss://mikun-testnet.tk:3001/ws",websocketInjected:WebSocket}});
alice = sym.Account.createFromPrivateKey("896E43895B908AF5847ECCB2645543751D94BD87E71058B003417FED5123****",networkType);
payload = Buffer.from("Test Data Here");
ms = await metal.MetalService.createForgeTxs(
sym.MetadataType.Account,
alice.address,
alice,
undefined,
payload
);
batches = await metal.SymbolService.buildSignedAggregateCompleteTxBatches(
ms.txs,
alice,
undefined,
);
errors = await metal.SymbolService.executeBatches(batches, alice);
> https://mikun-testnet.tk:3001/transactionStatus/50DC52DBC05A07252E3BA9156700735AAE3D1FE658D693F82FAA2D0CC6EEA722 404
batchesの中のpayloadがすでにマッピング不可能なpayloadになってしまっているようです。
sym.TransactionMapping.createFromPayload(batches[0].signedTx.payload)
> symbol-sdk-pack-2.0.3.js:44707 Uncaught RangeError
at GeneratorUtils.getBytes (symbol-sdk-pack-2.0.3.js:44707:19)
at PublicKeyDto.loadFromBinary (symbol-sdk-pack-2.0.3.js:128932:59)
at EmbeddedTransactionBuilder.loadFromBinary (symbol-sdk-pack-2.0.3.js:127905:61)
at loadFromBinary (symbol-sdk-pack-2.0.3.js:127998:80)
at GeneratorUtils.loadFromBinaryRemaining (symbol-sdk-pack-2.0.3.js:44765:26)
at AggregateTransactionBodyBuilder.loadFromBinary (symbol-sdk-pack-2.0.3.js:127405:62)
at AggregateCompleteTransactionBuilder.loadFromBinary (symbol-sdk-pack-2.0.3.js:42428:108)
at AggregateTransaction.createFromPayload (symbol-sdk-pack-2.0.3.js:120342:84)
at CreateTransactionFromPayload (symbol-sdk-pack-2.0.3.js:110931:51)
at TransactionMapping.createFromPayload (symbol-sdk-pack-2.0.3.js:106431:80)
200100000000000087BEFE9652B3AA926D7B97F040DEE95A8EB1CC18CFF7542ADA48A1E25AF54F20CD95B87498079F6DA3146D92C93180E81C7901704FC33666C72915A97A21B7070E5C72B0D5946C1EFEE7E5317C5985F106B739BB0BC07E4F9A288417B3CD6D2600000000029841418070000000000000925870B300000000D9FFB0AFBA8AAF0D90228A0440F0CD69DE75044A15AA0F242C3D3B3BD3146184780000000000000078000000000000009850BF0FD1A45FCEE211B57D0FE2B6421EB81979814F629200000000019844419850BF0FD1A45FCEE211B57D0FE2B6421EB81979814F6292374A380815E6DB012C002C004530313030303030464544433043393935414146373035375647567A64434245595852684945686C636D553D
なにかお気づきの点がありましたらご指摘ください。
以下で生成しているRepositoryFactoryHttpですが、
metal-on-symbol/src/services/symbol.ts
Line 99 in 166b6b5
コンストラクタで第二引数で指定できる、RepositoryFactoryConfigを指定したいです。
理由はbrowserでwebsocketを使用する場合に
websocketInjectedにWebSocket
を指定する必要があります。
browserではこんな感じで使用します。
ご検討よろしくお願いします。
タイトル通り、yarn でのbuild時に
../../../node_modules/@types/express-serve-static-core/index.d.ts:589:18 - error TS2430: Interface 'Response<ResBody, Locals, StatusCode>' incorrectly extends interface 'ServerResponse<IncomingMessage>'.
Types of property 'req' are incompatible.
Type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>> | undefined' is not assignable to type 'IncomingMessage'.
Type 'undefined' is not assignable to type 'IncomingMessage'.
589 export interface Response<
というエラーになりました
tsconfig.jsonのcompilerOptionsに"skipLibCheck": true
を追記すると消えました。
これはあまり良い回避策ではないようですが…
yarn -v
1.22.18
以上、報告させていただきます!
非常に興味深いプロトコルの提案、ありがとうございます。
metal-on-symbolをcliではなく、jsとしてhtmlの中で使用してみたいと思っています。
browserifyで変換してみると、jsファイルには変換できましたが、
metal = require("/node_modules/metal-on-symbol");
と読み込んでみると以下のようなメッセージが表示されました。
Metal CLI version 1.0
Usage: $ metal command [options]
Commands:
fetch Fetch on-chain metal and decode into file.
forge Upload the metal onto blockchain.
reinforce Cosigning forge/scrap intermediate transactions for multisig resolution.
scrap Scrap the metal on blockchain.
verify Verify off-chain file vs on-chain metal.
Options:
-h, --help Show command line usage.
どうやら読み込み時に引数を適切に指定しないとcommandがうまく使えないようです。
symbol-sdk(ver2系)をbrowserifyした場合、以下のような感じでメソッドを使えるようになります。
sym = require("/node_modules/symbol-sdk");
repo = new sym.RepositoryFactoryHttp(NODE);
accountRepo = repo.createAccountRepository();
このような感じでmeta-on-symbolを使うことは可能でしょうか?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.