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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| rateModel | RateModel | Exchange rate model |
| userId | string | User ID performing the exchange |
| count | int | Exchanging volume |
| config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | Whether to allow exchange | ||
| rateMode | string | ✓ | “float” | Rate mode | |
| rate | float | 1.0 | 0 ~ 1000 | Acquisition quantity rate | |
| logRate | LogRate | Logarithmic 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| rateModel | RateModel | Exchange rate model |
| userId | string | User ID performing the exchange |
| count | int | Exchanging volume |
| config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Required | Default | Value Limits | Description |
|---|
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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| rateModel | IncrementalRateModel | Exchange rate model |
| userId | string | User ID performing the exchange |
| count | int | Exchanging volume |
| config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| rateModel | IncrementalRateModel | Exchange rate model |
| userId | string | User ID performing the exchange |
| count | int | Exchanging volume |
| config | Config[] | Set values to be applied to transaction variables |
Result
| Type | Required | Default | Value Limits | Description |
|---|
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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| incrementalRateModel | IncrementalRateModel | Cost increase type exchange rate model |
| userId | string | User ID |
| currentExchangeCount | int | Current number of exchange counts |
| quantity | int | Exchange Quantity |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| costMode | string | ✓ | “num” | Cost calculation method | |
| cost | long | 0 ~ 9223372036854775805 | Cost | ||
| logCost | LogCost | Cost 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| rateModel | RateModel | Receive rate model |
| awaitModel | Await | Await |
Result
| Type | Required | Default | Value Limits | Description | |
|---|---|---|---|---|---|
| permit | bool | ✓ | 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
| Type | Description | |
|---|---|---|
| namespace | Namespace | Namespace |
| rateModel | RateModel | Receive rate model |
| awaitModel | Await | Await |
Result
| Type | Required | Default | Value Limits | Description |
|---|
Implementation Example
namespace = args.namespace
rateModel = args.rateModel
awaitModel = args.awaitModel
result = {
}