From 5aebefa3805ab251a7ca9ef938625ee25a387499 Mon Sep 17 00:00:00 2001 From: Aditya Sripal Date: Thu, 7 Jul 2022 12:53:33 +0200 Subject: [PATCH] update init cb --- spec/app/ics-029-fee-payment/README.md | 47 +++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/spec/app/ics-029-fee-payment/README.md b/spec/app/ics-029-fee-payment/README.md index 11b0eeb0e..bf316d5b1 100644 --- a/spec/app/ics-029-fee-payment/README.md +++ b/spec/app/ics-029-fee-payment/README.md @@ -252,27 +252,36 @@ function onChanOpenInit( counterpartyPortIdentifier: Identifier, counterpartyChannelIdentifier: Identifier, version: string): (version: string, err: Error) { - // try to unmarshal JSON-encoded version string and pass - // the app-specific version to app callback. - // otherwise, pass version directly to app callback. - metadata, err = UnmarshalJSON(version) - if err != nil { - // call the underlying applications OnChanOpenInit callback - return app.onChanOpenInit( - order, - connectionHops, - portIdentifier, - channelIdentifier, - counterpartyPortIdentifier, - counterpartyChannelIdentifier, - version, - ) + if version != "" { + // try to unmarshal JSON-encoded version string and pass + // the app-specific version to app callback. + // otherwise, pass version directly to app callback. + metadata, err = UnmarshalJSON(version) + if err != nil { + // call the underlying applications OnChanOpenInit callback + return app.onChanOpenInit( + order, + connectionHops, + portIdentifier, + channelIdentifier, + counterpartyPortIdentifier, + counterpartyChannelIdentifier, + version, + ) + } + + // check that feeVersion is supported + if !isSupported(metadata.feeVersion) { + return "", error + } + } else { + // enable fees by default if relayer does not specify otherwise + metadata = { + feeVersion: "ics29-1", + appVersion: "", + } } - // check that feeVersion is supported - if !isSupported(metadata.feeVersion) { - return "", error - } // call the underlying applications OnChanOpenInit callback. // if the version string is empty, OnChanOpenInit is expected to return // a default version string representing the version(s) it supports