diff --git a/wasm/main.go b/wasm/main.go index 644bb441..bba2c3c0 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -114,29 +114,36 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { resolve := args[0] reject := args[1] if len(funcArgs) != 4 { - reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, rpc, network)\"") + reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, rpc, network)\" or \"connect(beeEndpoint, stampId, rpc, network, subRpc, subContractAddress)\"") return nil } beeEndpoint := funcArgs[0].String() stampId := funcArgs[1].String() rpc := funcArgs[2].String() network := funcArgs[3].String() - //subRpc := funcArgs[4].String() - //subContractAddress := funcArgs[5].String() + subRpc := funcArgs[4].String() + subContractAddress := funcArgs[5].String() if network != "testnet" && network != "play" { reject.Invoke("unknown network. \"use play or testnet\"") return nil } var ( - config *contracts.ENSConfig + config *contracts.ENSConfig + subConfig *contracts.SubscriptionConfig ) if network == "play" { - config, _ = contracts.PlayConfig() + config, subConfig = contracts.PlayConfig() } else { - config, _ = contracts.TestnetConfig(contracts.Sepolia) + config, subConfig = contracts.TestnetConfig(contracts.Sepolia) } config.ProviderBackend = rpc + if subRpc != "" { + subConfig.RPC = subRpc + } + if subContractAddress != "" { + subConfig.DataHubAddress = subContractAddress + } logger := logging.New(os.Stdout, logrus.DebugLevel) go func() { @@ -145,7 +152,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { Stamp: stampId, BeeApiEndpoint: beeEndpoint, EnsConfig: config, - SubscriptionConfig: nil, + SubscriptionConfig: subConfig, Logger: logger, } api, err = dfs.NewDfsAPI(