Skip to content

Commit 6b13fda

Browse files
committed
cmd/rofl/provider: Init empty offer, refactor Offer.Payment
1 parent a46b411 commit 6b13fda

2 files changed

Lines changed: 42 additions & 11 deletions

File tree

build/rofl/provider/manifest.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,11 @@ const (
267267

268268
// Payment is payment configuration for an offer.
269269
type Payment struct {
270-
Native *struct {
271-
Denomination string `yaml:"denomination" json:"denomination"`
272-
Terms map[string]string `yaml:"terms" json:"terms"`
273-
} `yaml:"native,omitempty" json:"native,omitempty"`
274-
275-
EvmContract *struct {
276-
Address string `json:"address"`
277-
Data string `json:"data"`
278-
} `yaml:"evm,omitempty" json:"evm,omitempty"`
270+
// Native contains native payment terms.
271+
Native *NativePayment `yaml:"native,omitempty" json:"native,omitempty"`
272+
273+
// EvmContract contains payment terms defined in a smart contract.
274+
EvmContract *EVMContractPayment `yaml:"evm,omitempty" json:"evm,omitempty"`
279275
}
280276

281277
// Validate validates the payment configuration.
@@ -353,6 +349,24 @@ func (p *Payment) AsDescriptor(pt *config.ParaTime) (*roflmarket.Payment, error)
353349
return &dsc, nil
354350
}
355351

352+
// NativePayment is payment configuration for native tokens.
353+
type NativePayment struct {
354+
// Denomination is the native token denomination.
355+
Denomination string `yaml:"denomination,omitempty" json:"denomination,omitempty"`
356+
357+
// Terms are payment terms in form of Term => amount in decimal.
358+
Terms map[string]string `yaml:"terms" json:"terms"`
359+
}
360+
361+
// EVMContractPayment is payment configuration for EVM contract-based payments.
362+
type EVMContractPayment struct {
363+
// Address is hex-encoded address without leading 0x.
364+
Address string `json:"address"`
365+
366+
// Data is arbitrary Base-64 encoded payment information.
367+
Data string `json:"data"`
368+
}
369+
356370
// Resources are describe the offered resources.
357371
type Resources struct {
358372
// TEE is the type of TEE hardware.

cmd/rofl/provider/mgmt.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,31 @@ var (
4343
}
4444

4545
fmt.Printf("Scheduler app: %s\n", schedulerApp)
46-
47-
// Create a default manifest.
4846
manifest := provider.Manifest{
4947
Network: npa.NetworkName,
5048
ParaTime: npa.ParaTimeName,
5149
Provider: npa.AccountName,
5250
SchedulerApp: schedulerApp,
5351
PaymentAddress: npa.AccountName,
52+
Offers: []*provider.Offer{{
53+
ID: "example_offer",
54+
Note: "One-liner note for special discounts or warnings (optional)",
55+
Description: "This is an example offer.\nFill in your description here.",
56+
Resources: provider.Resources{
57+
TEE: "tdx",
58+
Memory: 1024,
59+
CPUCount: 1,
60+
Storage: 3000,
61+
},
62+
Payment: provider.Payment{
63+
Native: &provider.NativePayment{
64+
Terms: map[string]string{
65+
provider.TermKeyMonth: "100",
66+
},
67+
},
68+
},
69+
Capacity: 10,
70+
}},
5471
}
5572
err := manifest.Validate()
5673
cobra.CheckErr(err)

0 commit comments

Comments
 (0)