Script Trigger Reference of GS2-Exchange

Reference of event triggers that call extended scripts

Trigger

exchange

Exchange

Synchronous Execution Script

The script is executed synchronously before the exchange process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow exchange
rateModestring
“float”Rate mode
ratefloat1.00 ~ 1000Acquisition quantity rate
logRateLogRateLogarithmic acquisition correction
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
  permit=permit,
  rateMode=rateMode,
  rate=rate,
  logRate=logRate
}

Asynchronous Execution Script

The script executes asynchronously after the Exchange.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
}

incrementalExchange

Exchange

Synchronous Execution Script

The script is executed synchronously before the exchange process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelIncrementalRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow exchange
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
  permit=permit
}

Asynchronous Execution Script

The script executes asynchronously after the Exchange.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelIncrementalRateModelExchange rate model
userIdstringUser ID performing the exchange
countintExchanging volume
configConfig[]Set values to be applied to transaction variables
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
}

calculateCost

Costing scripts for cost increase exchange rate

Synchronous Execution Script

The script is executed synchronously before the costing scripts for cost increase exchange rate process.

Request
TypeDescription
namespaceNamespaceNamespace
incrementalRateModelIncrementalRateModelCost Increase Exchange Rate Model
userIdstringUser ID
currentExchangeCountintCurrent number of exchange counts
quantityintExchange Quantity
Result
TypeRequiredDefaultValue LimitsDescription
costModestring
“num”Cost calculation method
costlong0 ~ 9223372036854775805Cost
logCostLogCostCost calculation result using logarithm
Implementation Example
namespace = args.namespace
incrementalRateModel = args.incrementalRateModel
userId = args.userId
currentExchangeCount = args.currentExchangeCount
quantity = args.quantity

result = {
  costMode=costMode,
  cost=cost,
  logCost=logCost
}

acquireAwait

Exchange Await

Synchronous Execution Script

The script is executed synchronously before the exchange await process.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange Rate Model
awaitModelAwaitExchange Await
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow awaiting exchange
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
awaitModel = args.awaitModel

result = {
  permit=permit
}

Asynchronous Execution Script

The script executes asynchronously after the Exchange Await.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelExchange Rate Model
awaitModelAwaitExchange Await
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
awaitModel = args.awaitModel

result = {
}