Giter Site home page Giter Site logo

metal-on-symbol's People

Contributors

hanatyan128 avatar uzulla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

0x070696e65

metal-on-symbol's Issues

SDK から Node 固有機能を排除

MetalService が Buffer を使っているので、Uint8Array と適当な base64 トランスコーダに置き換え、よりブラウザフレンドリーにします。

Support binary metadata value

現在ペイロードが base64 にエンコードされているが、Metadata の値はバイナリも対応しているので、次のバージョンアップでバイナリ表現をサポートする。
尚、デコーダは従来の base64 にも引き続き対応すること。
(チャンクヘッダのバージョンで対応予定)

browserでうまくforgeができません。

以下のような手順で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生成時にRepositoryFactoryConfigを指定したい(browserで使用するWebSocket対応)

以下で生成しているRepositoryFactoryHttpですが、

const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);

コンストラクタで第二引数で指定できる、RepositoryFactoryConfigを指定したいです。

https://github.com/symbol/symbol-sdk-typescript-javascript/blob/f094ab4be762986c593b0dbb1cb9cd4791977a33/src/infrastructure/RepositoryFactoryHttp.ts#L82

理由はbrowserでwebsocketを使用する場合に
websocketInjectedにWebSocketを指定する必要があります。

https://github.com/symbol/symbol-sdk-typescript-javascript/blob/f9f12a6eab3df40582d7583f6b1835513dd4b3cf/src/infrastructure/RepositoryFactoryConfig.ts#L36

browserではこんな感じで使用します。

https://github.com/xembook/quick_learning_symbol/blob/main/10_observer.md#101-%E3%83%AA%E3%82%B9%E3%83%8A%E3%83%BC%E8%A8%AD%E5%AE%9A

ご検討よろしくお願いします。

yarn build時にエラー

タイトル通り、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

以上、報告させていただきます!

browserifyでjs化して使用したい

非常に興味深いプロトコルの提案、ありがとうございます。
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を使うことは可能でしょうか?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.