Skip to content

Commit

Permalink
Merge pull request #549 from fairDataSociety/staging
Browse files Browse the repository at this point in the history
wasm subscription args readded
  • Loading branch information
asabya authored Oct 13, 2023
2 parents 8cf27e2 + d90249a commit aab839d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions wasm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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(
Expand Down

0 comments on commit aab839d

Please sign in to comment.