github.com/stafiprotocol/go-substrate-rpc-client@v1.4.7/client/client_test.go (about) 1 package client_test 2 3 import ( 4 "fmt" 5 "math/big" 6 "os" 7 "testing" 8 9 "github.com/ethereum/go-ethereum/common/hexutil" 10 "github.com/sirupsen/logrus" 11 "github.com/stafiprotocol/chainbridge/utils/crypto/sr25519" 12 "github.com/stafiprotocol/chainbridge/utils/keystore" 13 "github.com/stafiprotocol/go-substrate-rpc-client/client" 14 "github.com/stafiprotocol/go-substrate-rpc-client/config" 15 "github.com/stafiprotocol/go-substrate-rpc-client/pkg/utils" 16 "github.com/stafiprotocol/go-substrate-rpc-client/types" 17 ) 18 19 var ( 20 AliceKey = keystore.TestKeyRing.SubstrateKeys[keystore.AliceKey].AsKeyringPair() 21 From = "31yavGB5CVb8EwpqKQaS9XY7JZcfbK6QpWPn5kkweHVpqcov" 22 LessPolka = "1334v66HrtqQndbugYxX9m56V6222m97LbavB4KAMmqgjsas" 23 From1 = "31d96Cq9idWQqPq3Ch5BFY84zrThVE3r98M7vG4xYaSWHwsX" 24 From2 = "1TgYb5x8xjsZRyL5bwvxUoAWBn36psr4viSMHbRXA8bkB2h" 25 Wen = "1swvN162p1siDjm63UhhWoa59bpPZTSNKGVcbCwHUYkfRRW" 26 Jun = "33RQ73d9XfPTaE2SV7dzdhQQ17YaeMQ4yzhzAQhhFVenxMuJ" 27 relay1 = "33xzQzUk75cAxt7i3hHb2XWwJNFqzcSULfoCRsAkiCG4jh5d" 28 KeystorePath = "/Users/tpkeeper/gowork/stafi/rtoken-relay/keys" 29 ) 30 31 var ( 32 tlog = client.NewLog() 33 ) 34 35 const ( 36 stafiTypesFile = "/Users/tpkeeper/gowork/stafi/rtoken-relay/network/stafi.json" 37 polkaTypesFile = "/Users/tpkeeper/gowork/stafi/rtoken-relay/network/polkadot.json" 38 kusamaTypesFile = "/Users/tpkeeper/gowork/stafi/rtoken-relay/network/kusama.json" 39 ) 40 41 func TestSarpcClient_GetChainEvents(t *testing.T) { 42 logrus.SetLevel(logrus.TraceLevel) 43 sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "wss://mainnet-rpc.stafi.io", "", client.AddressTypeAccountId, nil, tlog) 44 // sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "wss://scan-rpc.stafi.io", "", client.AddressTypeAccountId, nil, tlog) 45 //sc, err := client.NewGsrpcClient("wss://polkadot-test-rpc.stafi.io", polkaTypesFile, tlog) 46 // sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "ws://127.0.0.1:9944", "", client.AddressTypeAccountId, AliceKey, tlog) 47 48 // sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "wss://stafi-seiya.stafi.io", "", client.AddressTypeAccountId, AliceKey, tlog) 49 // sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://rpc.polkadot.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog, ) 50 // sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-rpc.stafi.io", kusamaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog, ) 51 if err != nil { 52 t.Fatal(err) 53 } 54 55 receiver, err := sc.GetRFisReceiver() 56 if err != nil { 57 t.Fatal(err) 58 } 59 t.Log(receiver) 60 // rate,err:=sc.GetEraRate(client.RKSM,4773) 61 // if err!=nil{ 62 // t.Fatal(err) 63 // } 64 // t.Log(rate) 65 66 // era,err:=sc.CurrentChainEra(client.RDOT) 67 // if err!=nil{ 68 // t.Fatal(err) 69 // } 70 // t.Log(era) 71 // rateLimit, err := sc.ActiveChangeRateLimit(client.RDOT) 72 // if err != nil { 73 // t.Fatal(err) 74 // } 75 // t.Log(rateLimit) 76 // 0xd6c1e8d44fe1b4b54773efa907ad6b404756bc761d625d4577264d663144ddd27025e075d5e2f6cde3cc051a31f0766000 77 // 0xd6c1e8d44fe1b4b54773efa907ad6b404ddad12338d5de7866ed2d6abb9f61dc4a9e6f9b8d43f6ad008f8c291929dee201 78 // for i:=14188841;i<1418884114188841;i++{ 79 80 // events, err := sc.GetEvents(uint64(i)) 81 // if err != nil { 82 // t.Fatal(err) 83 // } 84 // for _, e := range events { 85 // t.Log(e.EventId, e.ModuleId) 86 // if e.EventId == config.RFisWithdrawUnbondEventId { 87 // w, err := client.EventWithdrawUnbondData(e) 88 // if err != nil { 89 // t.Fatal(err) 90 // } 91 // t.Log(w) 92 // } 93 // } 94 // } 95 96 // wg := sync.WaitGroup{} 97 // for i := 1588890; i < 1588990; i++ { 98 // wg.Add(1) 99 // go func(height uint64) { 100 // defer func() { 101 // if err := recover(); err != nil { 102 // panic(height) 103 // } 104 // }() 105 // _, _ = sc.GetEvents(height) 106 // fmt.Println(height) 107 108 // wg.Done() 109 // }(uint64(i)) 110 // } 111 // wg.Wait() 112 } 113 114 func TestSarpcClient_GetChainEventNominationUpdated(t *testing.T) { 115 116 // sc, err := client.NewGsrpcClient(ChainTypeStafi, "wss://stafi-seiya.stafi.io", stafiTypesFile, AddressTypeAccountId, AliceKey, tlog, ) 117 sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "wss://mainnet-rpc.stafi.io", stafiTypesFile, client.AddressTypeAccountId, AliceKey, tlog) 118 // sc, err := client.NewGsrpcClient(client.ChainTypePolkadot,"wss://polkadot-test-rpc.stafi.io", polkaTypesFile, AddressTypeAccountId, AliceKey, tlog, ) 119 if err != nil { 120 t.Fatal(err) 121 } 122 123 symbz, err := types.EncodeToBytes(client.RKSM) 124 if err != nil { 125 t.Fatal(err) 126 } 127 bondedPools := make([]types.Bytes, 0) 128 exist, err := sc.QueryStorage(config.RTokenLedgerModuleId, config.StorageBondedPools, symbz, nil, &bondedPools) 129 if err != nil { 130 t.Fatal(err) 131 } 132 if !exist { 133 t.Fatal("bonded pools not extis") 134 } 135 136 t.Log(bondedPools) 137 138 evts, err := sc.GetEvents(11561482) 139 if err != nil { 140 t.Fatal(err) 141 } 142 for _, evt := range evts { 143 if evt.EventId != config.NominationUpdatedEventId { 144 continue 145 } 146 } 147 } 148 149 func TestSarpcClient_GetExtrinsics1(t *testing.T) { 150 //sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://polkadot-test-rpc.stafi.io", polkaTypesFile, tlog) 151 //sc, err := client.NewGsrpcClient("wss://stafi-seiya.stafi.io", stafiTypesFile, tlog) 152 153 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://rpc.polkadot.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog) 154 if err != nil { 155 t.Fatal(err) 156 } 157 158 for i := 7411010; i >= 7311010; i-- { 159 if i%10 == 0 { 160 t.Log("i", i) 161 } 162 163 bh, err := sc.GetBlockHash(uint64(i)) 164 if err != nil { 165 t.Fatal(err) 166 } 167 exts, err := sc.GetExtrinsics(bh) 168 if err != nil { 169 t.Fatal(err) 170 } 171 172 for _, ext := range exts { 173 t.Log("exthash", ext.ExtrinsicHash) 174 t.Log("moduleName", ext.CallModuleName) 175 t.Log("methodName", ext.CallName) 176 t.Log("address", ext.Address) 177 t.Log(ext.Params) 178 //for _, p := range ext.Params { 179 // if p.Name == config.ParamDest && p.Type == config.ParamDestType { 180 // //dest, ok := p.Value.(string) 181 // //fmt.Println("ok", ok) 182 // //fmt.Println(dest) 183 // 184 // // polkadot-test 185 // dest, ok := p.Value.(map[string]interface{}) 186 // t.Log("ok", ok) 187 // v, ok := dest["Id"] 188 // t.Log("ok1", ok) 189 // val, ok := v.(string) 190 // t.Log("ok2", ok) 191 // t.Log(val) 192 // } 193 // 194 // t.Log("name", p.Name, "value", p.Value, "type", p.Type) 195 //} 196 } 197 } 198 } 199 200 func TestSarpcClient_GetExtrinsics2(t *testing.T) { 201 202 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-rpc.polkadot.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog) 203 if err != nil { 204 t.Fatal(err) 205 } 206 207 exts, err := sc.GetExtrinsics("0x6157da60a188b3f31d250afe5acb2da786417fec00973f1c7f863504fbca4642") 208 if err != nil { 209 t.Fatal(err) 210 } 211 212 for _, ext := range exts { 213 t.Log("exthash", ext.ExtrinsicHash) 214 t.Log("moduleName", ext.CallModuleName) 215 t.Log("methodName", ext.CallName) 216 t.Log("address", ext.Address) 217 t.Log(ext.Params) 218 for _, p := range ext.Params { 219 if p.Name == config.ParamDest && p.Type == config.ParamDestType { 220 //dest, ok := p.Value.(string) 221 //fmt.Println("ok", ok) 222 //fmt.Println(dest) 223 224 // polkadot-test 225 dest, ok := p.Value.(map[string]interface{}) 226 t.Log("ok", ok) 227 v, ok := dest["Id"] 228 t.Log("ok1", ok) 229 val, ok := v.(string) 230 t.Log("ok2", ok) 231 t.Log(val) 232 } 233 234 t.Log("name", p.Name, "value", p.Value, "type", p.Type) 235 } 236 } 237 } 238 239 func TestBatchTransfer(t *testing.T) { 240 241 sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "ws://127.0.0.1:9944", stafiTypesFile, client.AddressTypeAccountId, AliceKey, tlog) 242 if err != nil { 243 t.Fatal(err) 244 } 245 246 less, _ := types.NewAddressFromHexAccountID("0x3673009bdb664a3f3b6d9f69c9dd37fc0473551a249aa48542408b016ec62b2e") 247 jun, _ := types.NewAddressFromHexAccountID("0x765f3681fcc33aba624a09833455a3fd971d6791a8f2c57440626cd119530860") 248 wen, _ := types.NewAddressFromHexAccountID("0x26db25c52b007221331a844e5335e59874e45b03e81c3d76ff007377c2c17965") 249 bao, _ := types.NewAddressFromHexAccountID("0x9c4189297ad2140c85861f64656d1d1318994599130d98b75ff094176d2ca31e") 250 251 addrs := []types.Address{less, jun, wen, bao} 252 253 amount, _ := utils.StringToBigint("3000" + "000000000000") 254 value := types.NewUCompact(amount) 255 calls := make([]types.Call, 0) 256 257 ci, err := sc.FindCallIndex(config.MethodTransferKeepAlive) 258 if err != nil { 259 t.Fatal(err) 260 } 261 262 for _, addr := range addrs { 263 call, err := types.NewCallWithCallIndex( 264 ci, 265 config.MethodTransferKeepAlive, 266 addr, 267 value, 268 ) 269 if err != nil { 270 t.Fatal(err) 271 } 272 calls = append(calls, call) 273 } 274 275 ext, err := sc.NewUnsignedExtrinsic(config.MethodBatch, calls) 276 if err != nil { 277 t.Fatal(err) 278 } 279 280 err = sc.SignAndSubmitTx(ext) 281 if err != nil { 282 t.Fatal(err) 283 } 284 } 285 286 func TestGetConst(t *testing.T) { 287 288 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-rpc.polkadot.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog) 289 if err != nil { 290 t.Fatal(err) 291 } 292 293 e, err := sc.ExistentialDeposit() 294 if err != nil { 295 t.Fatal(err) 296 } 297 fmt.Println(e) 298 } 299 300 func TestPolkaQueryStorage(t *testing.T) { 301 302 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-rpc.polkadot.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog) 303 if err != nil { 304 t.Fatal(err) 305 } 306 307 var index uint32 308 exist, err := sc.QueryStorage(config.StakingModuleId, config.StorageActiveEra, nil, nil, &index) 309 if err != nil { 310 panic(err) 311 } 312 313 if !exist { 314 panic("not exist") 315 } 316 317 t.Log(index) 318 } 319 320 func TestStafiLocalQueryActiveEra(t *testing.T) { 321 322 sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "ws://127.0.0.1:9944", stafiTypesFile, client.AddressTypeAccountId, AliceKey, tlog) 323 if err != nil { 324 t.Fatal(err) 325 } 326 327 var index uint32 328 exist, err := sc.QueryStorage(config.StakingModuleId, config.StorageActiveEra, nil, nil, &index) 329 if err != nil { 330 t.Fatal(err) 331 } 332 t.Log(exist) 333 t.Log("activeEra", index) 334 } 335 336 func TestActive(t *testing.T) { 337 338 //sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-test-rpc.stafi.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog, ) 339 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-test-rpc.stafi.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog) 340 if err != nil { 341 t.Fatal(err) 342 } 343 344 a := "0xac0df419ce0dc61b092a5cfa06a28e40cd82bc9de7e8c1e5591169360d66ba3c" 345 mac, err := types.NewMultiAddressFromHexAccountID(a) 346 if err != nil { 347 t.Fatal(err) 348 } 349 ledger := new(client.StakingLedger) 350 exist, err := sc.QueryStorage(config.StakingModuleId, config.StorageLedger, mac.AsID[:], nil, ledger) 351 if err != nil { 352 t.Fatal(err) 353 } 354 t.Log(exist) 355 t.Log("ledger", ledger) 356 357 t.Log(types.NewU128(big.Int(ledger.Active))) 358 } 359 360 func TestActive1(t *testing.T) { 361 362 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://polkadot-test-rpc.stafi.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog) 363 if err != nil { 364 t.Fatal(err) 365 } 366 367 a := "0x782a467d4ff23b660ca5f1ecf47f8537d4c35049541b6ebbf5381c00c4c158f7" 368 b, _ := hexutil.Decode(a) // work 369 //mac, err := types.NewAddressFromHexAccountID(a) // work 370 //mac, err := types.NewMultiAddressFromHexAccountID(a) // work 371 ledger := new(client.StakingLedger) 372 exist, err := sc.QueryStorage(config.StakingModuleId, config.StorageLedger, b, nil, ledger) 373 if err != nil { 374 t.Fatal(err) 375 } 376 t.Log(exist) 377 t.Log(types.NewU128(big.Int(ledger.Active))) 378 } 379 380 func TestHash(t *testing.T) { 381 h, _ := types.NewHashFromHexString("0x26db25c52b007221331a844e5335e59874e45b03e81c3d76ff007377c2c17965") 382 a, _ := types.EncodeToBytes(h) 383 384 fmt.Println(hexutil.Encode(a)) 385 } 386 387 func TestPool(t *testing.T) { 388 p := "0x782a467d4ff23b660ca5f1ecf47f8537d4c35049541b6ebbf5381c00c4c158f7" 389 pool, _ := hexutil.Decode(p) 390 pbz, _ := types.EncodeToBytes(pool) 391 fmt.Println(pool) 392 fmt.Println(pbz) 393 394 // 395 //gc, err := client.NewGsrpcClient("wss://stafi-seiya.stafi.io", AddressTypeAccountId, AliceKey, tlog, ) 396 //assert.NoError(t, err) 397 // 398 // 399 ////poolBz, err := types.EncodeToBytes(pool) 400 //symBz, err := types.EncodeToBytes(core.RKSM) 401 //assert.NoError(t, err) 402 // 403 //var threshold uint16 404 //exist, err := gc.QueryStorage(config.RTokenLedgerModuleId, config.StorageMultiThresholds, symBz, pbz, &threshold) 405 //assert.NoError(t, err) 406 //fmt.Println(exist) 407 //fmt.Println() 408 409 } 410 411 func Test_KSM_GsrpcClient_Multisig(t *testing.T) { 412 413 logrus.SetLevel(logrus.TraceLevel) 414 415 password := "tpkeeper" 416 os.Setenv(keystore.EnvPassword, password) 417 418 kp, err := keystore.KeypairFromAddress(relay1, keystore.SubChain, KeystorePath, false) 419 if err != nil { 420 t.Fatal(err) 421 } 422 423 krp := kp.(*sr25519.Keypair).AsKeyringPair() 424 425 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-test-rpc.stafi.io", kusamaTypesFile, client.AddressTypeMultiAddress, krp, tlog) 426 if err != nil { 427 t.Fatal(err) 428 } 429 _ = sc 430 431 //pool, err := hexutil.Decode("ac0df419ce0dc61b092a5cfa06a28e40cd82bc9de7e8c1e5591169360d66ba3c") 432 //assert.NoError(t, err) 433 434 // threshold := uint16(2) 435 // //wen, _ := types.NewAddressFromHexAccountID("0x26db25c52b007221331a844e5335e59874e45b03e81c3d76ff007377c2c17965") 436 // // jun, _ := types.NewAddressFromHexAccountID("0x765f3681fcc33aba624a09833455a3fd971d6791a8f2c57440626cd119530860") 437 // relay2, _ := types.NewMultiAddressFromHexAccountID("0x2afeb305f32a12507a6b211d818218577b0e425692766b08b8bc5d714fccac3b") 438 439 // others := []types.AccountID{ 440 // relay2.AsID, 441 // } 442 443 //for _, oth := range others { 444 // fmt.Println(hexutil.Encode(oth[:])) 445 //} 446 447 // bond, _ := utils.StringToBigint("1000000000000") 448 // unbond := big.NewInt(0) 449 450 // call, err := sc.BondOrUnbondCall(bond, unbond) 451 // if err != nil { 452 // t.Fatal(err) 453 // } 454 455 // h := utils.BlakeTwo256(call.Opaque) 456 // t.Log("Extrinsic", call.Extrinsic) 457 // t.Log("Opaque", hexutil.Encode(call.Opaque)) 458 // t.Log("callHash", hexutil.Encode(h[:])) 459 460 // info, err := sc.GetPaymentQueryInfo(call.Extrinsic) 461 // if err != nil { 462 // t.Fatal(err) 463 // } 464 // t.Log("info", info.Class, info.PartialFee, info.Weight) 465 466 //optp := types.TimePoint{Height: 1964877, Index: 1} 467 //tp := submodel.NewOptionTimePoint(optp) 468 469 // tp := client.NewOptionTimePointEmpty() 470 // ext, err := sc.NewUnsignedExtrinsic(config.MethodAsMulti, threshold, others, tp, call.Opaque, false, info.Weight) 471 // if err != nil { 472 // t.Fatal(err) 473 // } 474 475 // err = sc.SignAndSubmitTx(ext) 476 // if err != nil { 477 // t.Fatal(err) 478 // } 479 } 480 func Test_KSM_GsrpcClient_transfer(t *testing.T) { 481 482 logrus.SetLevel(logrus.TraceLevel) 483 484 password := "tpkeeper" 485 os.Setenv(keystore.EnvPassword, password) 486 487 kp, err := keystore.KeypairFromAddress(relay1, keystore.SubChain, KeystorePath, false) 488 if err != nil { 489 t.Fatal(err) 490 } 491 492 krp := kp.(*sr25519.Keypair).AsKeyringPair() 493 494 // sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-test-rpc.stafi.io", kusamaTypesFile, AddressTypeAccountId, krp, tlog, ) 495 sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "ws://127.0.0.1:9944", kusamaTypesFile, client.AddressTypeMultiAddress, krp, tlog) 496 if err != nil { 497 t.Fatal(err) 498 } 499 500 //pool, err := hexutil.Decode("ac0df419ce0dc61b092a5cfa06a28e40cd82bc9de7e8c1e5591169360d66ba3c") 501 //assert.NoError(t, err) 502 503 // threshold := uint16(2) 504 //wen, _ := types.NewAddressFromHexAccountID("0x26db25c52b007221331a844e5335e59874e45b03e81c3d76ff007377c2c17965") 505 // jun, _ := types.NewAddressFromHexAccountID("0x765f3681fcc33aba624a09833455a3fd971d6791a8f2c57440626cd119530860") 506 relay2, _ := types.NewMultiAddressFromHexAccountID("0x2afeb305f32a12507a6b211d818218577b0e425692766b08b8bc5d714fccac3b") 507 508 // others := []types.AccountID{ 509 // relay2.AsAccountID, 510 // } 511 512 //for _, oth := range others { 513 // fmt.Println(hexutil.Encode(oth[:])) 514 //} 515 516 // bond, _ := utils.StringToBigint("1000000000000") 517 // unbond := big.NewInt(0) 518 519 // call,err:=sc.TransferCall(relay2.AsAccountID[:],types.NewUCompact(big.NewInt(1000000))) 520 // if err!=nil{ 521 // t.Fatal(err) 522 // } 523 ext, err := sc.NewUnsignedExtrinsic(config.MethodTransfer, relay2, types.NewUCompact(big.NewInt(1e10))) 524 if err != nil { 525 t.Fatal(err) 526 } 527 528 // call, err := sc.BondOrUnbondCall(bond, unbond) 529 // if err != nil { 530 // t.Fatal(err) 531 // } 532 533 // h := utils.BlakeTwo256(call.Opaque) 534 // t.Log("Extrinsic", call.Extrinsic) 535 // t.Log("Opaque", hexutil.Encode(call.Opaque)) 536 // t.Log("callHash", hexutil.Encode(h[:])) 537 538 // info, err := sc.GetPaymentQueryInfo(call.Extrinsic) 539 // if err != nil { 540 // t.Fatal(err) 541 // } 542 // t.Log("info", info.Class, info.PartialFee, info.Weight) 543 544 //optp := types.TimePoint{Height: 1964877, Index: 1} 545 //tp := submodel.NewOptionTimePoint(optp) 546 547 // tp := submodel.NewOptionTimePointEmpty() 548 // ext, err := sc.NewUnsignedExtrinsic(config.MethodAsMulti, threshold, others, tp, call.Opaque, false, info.Weight) 549 // if err != nil { 550 // t.Fatal(err) 551 // } 552 err = sc.SignAndSubmitTx(ext) 553 if err != nil { 554 t.Fatal(err) 555 } 556 } 557 func TestSarpcClient_MintTxhashExist(t *testing.T) { 558 //sc, err := client.NewGsrpcClient("wss://mainnet-rpc.stafi.io", stafiTypesFile, tlog) 559 //sc, err := client.NewGsrpcClient("wss://polkadot-test-rpc.stafi.io", polkaTypesFile, tlog) 560 sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "ws://127.0.0.1:9944", stafiTypesFile, client.AddressTypeAccountId, AliceKey, tlog) 561 562 // sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "wss://stafi-seiya.stafi.io", "", client.AddressTypeAccountId, AliceKey, tlog) 563 // sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-rpc.polkadot.io", polkaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog, ) 564 // sc, err := client.NewGsrpcClient(client.ChainTypePolkadot, "wss://kusama-rpc.stafi.io", kusamaTypesFile, client.AddressTypeMultiAddress, AliceKey, tlog, ) 565 if err != nil { 566 t.Fatal(err) 567 } 568 exist, err := sc.MintTxHashExist(types.NewBytes(hexutil.MustDecode("0x12345678"))) 569 if err != nil { 570 t.Fatal(err) 571 } 572 t.Log(exist) 573 } 574 575 func TestSarpcClient_RTokenTotalIssuance(t *testing.T) { 576 577 // sc, err := client.NewGsrpcClient(ChainTypeStafi, "wss://stafi-seiya.stafi.io", stafiTypesFile, AddressTypeAccountId, AliceKey, tlog, ) 578 sc, err := client.NewGsrpcClient(client.ChainTypeStafi, "wss://mainnet-rpc.stafi.io", stafiTypesFile, client.AddressTypeAccountId, AliceKey, tlog) 579 // sc, err := client.NewGsrpcClient(client.ChainTypePolkadot,"wss://polkadot-test-rpc.stafi.io", polkaTypesFile, AddressTypeAccountId, AliceKey, tlog, ) 580 if err != nil { 581 t.Fatal(err) 582 583 } 584 issuance, err := sc.RTokenTotalIssuance(client.RFIS) 585 if err != nil { 586 t.Fatal(err) 587 } 588 t.Log(issuance) 589 }