Trigger Reference of GS2-Exchange Script

Reference of event triggers that call extended scripts

Trigger

exchange

Exchange

Synchronous Execution Script

Script and Exchange are executed synchronously in that order.

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 will run after the Exchange is executed.

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
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
}

incrementalExchange

Exchange

Synchronous Execution Script

Script and Exchange are executed synchronously in that order.

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 will run after the Exchange is executed.

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
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
userId = args.userId
count = args.count
config = args.config

result = {
}

calculateCost

Costing scripts for cost increase type exchange rate

Synchronous Execution Script

Script and Costing scripts for cost increase type exchange rate are executed synchronously in that order.

Request
TypeDescription
namespaceNamespaceNamespace
incrementalRateModelIncrementalRateModelCost increase type 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

Await

Synchronous Execution Script

Script and Await are executed synchronously in that order.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelReceive rate model
awaitModelAwaitAwait
Result
TypeRequiredDefaultValue LimitsDescription
permitbool
Whether to allow receive
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
awaitModel = args.awaitModel

result = {
  permit=permit
}

Asynchronous Execution Script

The script will run after the Await is executed.

Request
TypeDescription
namespaceNamespaceNamespace
rateModelRateModelReceive rate model
awaitModelAwaitAwait
Result
TypeRequiredDefaultValue LimitsDescription
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
awaitModel = args.awaitModel

result = {
}