diff --git a/README.md b/README.md index 816ba0f..3c78dcb 100644 --- a/README.md +++ b/README.md @@ -410,12 +410,12 @@ When you are done, the output should look something like this: ``` database: .nuklai-cli address: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx -chainID: jLqD1HxDRb54NpfK7Psb6bkhAHghF36VcokJ6kvSBGZpTT6aj +chainID: N5Chcji7s7wAxukcoanm98MdjVKVwR5W3vzcp9tv2VpRknENs symbol: TOKEN1 -decimals: 9 -✔ metadata: Example token1█ +✔ decimals: 9█ +metadata: Example token1 ✔ continue (y/n): y█ -✅ txID: 2sq8ThNtmd3ijEsvYUqBgrEkJqFGW9m6b2EmiDKt6ehaFai3qA +✅ txID: ggMxHuutoobCLfuYyiLRYr1VMq7r9ULcBU621kvurtsqdifjN ``` _`txID` is the `assetID` of your new asset._ @@ -438,13 +438,13 @@ just to mint to yourself). ``` database: .nuklai-cli address: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx -chainID: jLqD1HxDRb54NpfK7Psb6bkhAHghF36VcokJ6kvSBGZpTT6aj -assetID: 2sq8ThNtmd3ijEsvYUqBgrEkJqFGW9m6b2EmiDKt6ehaFai3qA +chainID: N5Chcji7s7wAxukcoanm98MdjVKVwR5W3vzcp9tv2VpRknENs +assetID: ggMxHuutoobCLfuYyiLRYr1VMq7r9ULcBU621kvurtsqdifjN symbol: TOKEN1 decimals: 9 metadata: Example token1 supply: 0 recipient: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx -✔ amount: 100█ +✔ amount: 1000█ continue (y/n): y -✅ txID: 2DzquqEAKXUgQZHgQfnaxnUjEhyFrRsna5d995Tr9Lzu7EdJ8R +✅ txID: 2eG6m32NMgaxdz36W8omF1tQNBAkXr2JHojsU67X1AQzT73PSf ``` #### Step 3: View Your Balance @@ -461,11 +461,11 @@ When you are done, the output should look something like this: ``` database: .nuklai-cli address: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx -chainID: jLqD1HxDRb54NpfK7Psb6bkhAHghF36VcokJ6kvSBGZpTT6aj -✔ assetID (use NAI for native token): 2sq8ThNtmd3ijEsvYUqBgrEkJqFGW9m6b2EmiDKt6ehaFai3qA█ -uri: http://127.0.0.1:42719/ext/bc/jLqD1HxDRb54NpfK7Psb6bkhAHghF36VcokJ6kvSBGZpTT6aj -symbol: TOKEN1 decimals: 9 metadata: Example token1 supply: 100000000000 warp: false -balance: 100.000000000 TOKEN1 +chainID: N5Chcji7s7wAxukcoanm98MdjVKVwR5W3vzcp9tv2VpRknENs +assetID (use NAI for native token): ggMxHuutoobCLfuYyiLRYr1VMq7r9ULcBU621kvurtsqdifjN +uri: http://127.0.0.1:43689/ext/bc/N5Chcji7s7wAxukcoanm98MdjVKVwR5W3vzcp9tv2VpRknENs +symbol: TOKEN1 decimals: 9 metadata: Example token1 supply: 1000000000000 warp: false +balance: 1000.000000000 TOKEN1 ``` ### Transfer Assets to Another Subnet @@ -483,22 +483,22 @@ When you are done, the output should look something like this: ``` database: .nuklai-cli address: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx -chainID: jLqD1HxDRb54NpfK7Psb6bkhAHghF36VcokJ6kvSBGZpTT6aj -✔ assetID (use NAI for native token): NAI█ -balance: 852999999.999939919 NAI -✔ recipient: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx█ -amount: 50 -reward: 0 -available chains: 1 excluded: [jLqD1HxDRb54NpfK7Psb6bkhAHghF36VcokJ6kvSBGZpTT6aj] -0) chainID: Ua7vvdAAHzYG2nFaQ33kamYGnvnRPeTaHoifzB3RxyBPmubKr +chainID: N5Chcji7s7wAxukcoanm98MdjVKVwR5W3vzcp9tv2VpRknENs +✔ assetID (use NAI for native token): ggMxHuutoobCLfuYyiLRYr1VMq7r9ULcBU621kvurtsqdifjN█ +symbol: TOKEN1 decimals: 9 metadata: Example token1 supply: 1000000000000 warp: false +balance: 1000.000000000 TOKEN1 +recipient: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx +✔ amount: 50█ +✔ reward: 0█ +available chains: 1 excluded: [N5Chcji7s7wAxukcoanm98MdjVKVwR5W3vzcp9tv2VpRknENs] +0) chainID: qttmKGHGjHfj6749KJxaSzfD1xuhKRrFFjM6TypthH2TSxuLK destination: 0 [auto-selected] -✔ swap on import (y/n): n█ -✔ continue (y/n): y█ -✅ txID: 2K4Sb9xNPsenCUcM6EXUQAqgvrPWX2e3NLUcSXNGmeRXVbytVt +continue (y/n): y +✅ txID: 2LwezG85VjTktvfZpwnGigvqH3o74ZC9qBWmWUwjsXmqAwQMsV perform import on destination (y/n): y -3kvVpqa78MG2gTWtfKSvhPryHkKVaWhMEWQ8sL2xBAtVRiChh to: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx source assetID: 11111111111111111111111111111111LpoYY source symbol: NAI output assetID: wkaZgTapGBi122S9deE8XSPd3VunJK6mCBF4ZRBU72sm6Em82 value: 50.000000000 reward: 0.000000000 return: false -signature weight: 5000 total weight: 5000 -✔ switch default chain to destination (y/n): y +2RiJax29P6XVQzeXXApigqBBcsmrZjJ1vXKPBv1RaTKc5mqaxW to: nuklai1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjss0gwx source assetID: ggMxHuutoobCLfuYyiLRYr1VMq7r9ULcBU621kvurtsqdifjN source symbol: TOKEN1 output assetID: 7W44tf7zcvWW9MYLLvQdoL6Uf7L5MZ2vgNdGqYJ5caeEbMiuB value: 50.000000000 reward: 0.000000000 return: false +✅ txID: FLkYqXKMmE9HwKksdmiwyJberPzq4zEeEupwHDgDcAXkhjmGX +✔ switch default chain to destination (y/n): y█ ``` _The `export` command will automatically run the `import` command on the diff --git a/cmd/nuklai-cli/cmd/action.go b/cmd/nuklai-cli/cmd/action.go index c0c1280..de0cfb6 100644 --- a/cmd/nuklai-cli/cmd/action.go +++ b/cmd/nuklai-cli/cmd/action.go @@ -367,10 +367,10 @@ var mintAssetCmd = &cobra.Command{ func performImport( ctx context.Context, - srcHcli *hrpc.JSONRPCClient, - destHcli *hrpc.JSONRPCClient, - destHws *hrpc.WebSocketClient, - destNcli *nrpc.JSONRPCClient, + hscli *hrpc.JSONRPCClient, + hdcli *hrpc.JSONRPCClient, + hws *hrpc.WebSocketClient, + ncli *nrpc.JSONRPCClient, exportTxID ids.ID, factory chain.AuthFactory, ) error { @@ -389,7 +389,7 @@ func performImport( subnetWeight, sigWeight uint64 ) for ctx.Err() == nil { - msg, subnetWeight, sigWeight, err = srcHcli.GenerateAggregateWarpSignature(ctx, exportTxID) + msg, subnetWeight, sigWeight, err = hscli.GenerateAggregateWarpSignature(ctx, exportTxID) if sigWeight >= (subnetWeight*4)/5 && err == nil { break } @@ -436,7 +436,7 @@ func performImport( wt.Return, ) if wt.SwapIn > 0 { - _, outSymbol, outDecimals, _, _, _, _, err := destNcli.Asset(ctx, wt.AssetOut, false) + _, outSymbol, outDecimals, _, _, _, _, err := ncli.Asset(ctx, wt.AssetOut, false) if err != nil { return err } @@ -450,11 +450,6 @@ func performImport( wt.SwapExpiry, ) } - hutils.Outf( - "{{yellow}}signature weight:{{/}} %d {{yellow}}total weight:{{/}} %d\n", - sigWeight, - subnetWeight, - ) // Select fill var fill bool @@ -471,7 +466,7 @@ func performImport( // Generate transaction _, _, err = sendAndWait(ctx, msg, &actions.ImportAsset{ Fill: fill, - }, destHcli, destHws, destNcli, factory, true) + }, hdcli, hws, ncli, factory, true) return err } @@ -479,7 +474,8 @@ var importAssetCmd = &cobra.Command{ Use: "import-asset", RunE: func(*cobra.Command, []string) error { ctx := context.Background() - currentChainID, _, factory, dcli, dscli, dtcli, err := handler.DefaultActor() + + currentChainID, _, factory, hdcli, hws, ncli, err := handler.DefaultActor() if err != nil { return err } @@ -489,10 +485,10 @@ var importAssetCmd = &cobra.Command{ if err != nil { return err } - scli := hrpc.NewJSONRPCClient(uris[0]) + hscli := hrpc.NewJSONRPCClient(uris[0]) // Perform import - return performImport(ctx, scli, dcli, dscli, dtcli, ids.Empty, factory) + return performImport(ctx, hscli, hdcli, hws, ncli, ids.Empty, factory) }, } @@ -636,11 +632,11 @@ var exportAssetCmd = &cobra.Command{ if err != nil { return err } - dscli, err := hrpc.NewWebSocketClient(uris[0], hrpc.DefaultHandshakeTimeout, pubsub.MaxPendingMessages, pubsub.MaxReadMessageSize) + hdcli, err := hrpc.NewWebSocketClient(uris[0], hrpc.DefaultHandshakeTimeout, pubsub.MaxPendingMessages, pubsub.MaxReadMessageSize) if err != nil { return err } - if err := performImport(ctx, hcli, hrpc.NewJSONRPCClient(uris[0]), dscli, nrpc.NewJSONRPCClient(uris[0], networkID, destination), txID, factory); err != nil { + if err := performImport(ctx, hcli, hrpc.NewJSONRPCClient(uris[0]), hdcli, nrpc.NewJSONRPCClient(uris[0], networkID, destination), txID, factory); err != nil { return err } } diff --git a/cmd/nuklai-cli/cmd/handler.go b/cmd/nuklai-cli/cmd/handler.go index 9255d02..9a478cb 100644 --- a/cmd/nuklai-cli/cmd/handler.go +++ b/cmd/nuklai-cli/cmd/handler.go @@ -109,6 +109,7 @@ func (h *Handler) DefaultActor() ( if err != nil { return ids.Empty, nil, nil, nil, nil, nil, err } + var factory chain.AuthFactory switch addr[0] { case nconsts.ED25519ID: @@ -124,6 +125,7 @@ func (h *Handler) DefaultActor() ( default: return ids.Empty, nil, nil, nil, nil, nil, ErrInvalidAddress } + chainID, uris, err := h.h.GetDefaultChain(true) if err != nil { return ids.Empty, nil, nil, nil, nil, nil, err