@@ -26,18 +26,32 @@ export async function up({ context }: Context): Promise<void> {
26
26
primaryKey : true ,
27
27
autoIncrement : true ,
28
28
} ,
29
- allocation_id : {
30
- type : DataTypes . CHAR ( 40 ) ,
31
- allowNull : false ,
32
- } ,
33
29
signer_address : {
34
30
type : DataTypes . CHAR ( 40 ) ,
35
31
allowNull : false ,
36
32
} ,
33
+
34
+ // Values below are the individual fields of the EIP-712 receipt
37
35
signature : {
38
36
type : DataTypes . BLOB ,
39
37
allowNull : false ,
40
38
} ,
39
+ collection_id : {
40
+ type : DataTypes . CHAR ( 64 ) ,
41
+ allowNull : false ,
42
+ } ,
43
+ payer : {
44
+ type : DataTypes . CHAR ( 40 ) ,
45
+ allowNull : false ,
46
+ } ,
47
+ data_service : {
48
+ type : DataTypes . CHAR ( 40 ) ,
49
+ allowNull : false ,
50
+ } ,
51
+ service_provider : {
52
+ type : DataTypes . CHAR ( 40 ) ,
53
+ allowNull : false ,
54
+ } ,
41
55
timestamp_ns : {
42
56
type : DataTypes . DECIMAL ( 20 ) ,
43
57
allowNull : false ,
@@ -59,7 +73,7 @@ export async function up({ context }: Context): Promise<void> {
59
73
RETURNS trigger AS
60
74
$$
61
75
BEGIN
62
- PERFORM pg_notify('tap_horizon_receipt_notification', format('{"id": %s, "allocation_id ": "%s", "signer_address": "%s", "timestamp_ns": %s, "value": %s}', NEW.id, NEW.allocation_id , NEW.signer_address, NEW.timestamp_ns, NEW.value));
76
+ PERFORM pg_notify('tap_horizon_receipt_notification', format('{"id": %s, "collection_id ": "%s", "signer_address": "%s", "timestamp_ns": %s, "value": %s}', NEW.id, NEW.collection_id , NEW.signer_address, NEW.timestamp_ns, NEW.value));
63
77
RETURN NEW;
64
78
END;
65
79
$$ LANGUAGE 'plpgsql';
@@ -72,8 +86,8 @@ export async function up({ context }: Context): Promise<void> {
72
86
await queryInterface . sequelize . query ( functionSQL )
73
87
await queryInterface . sequelize . query ( triggerSQL )
74
88
75
- queryInterface . addIndex ( 'tap_horizon_receipts' , [ 'allocation_id ' ] , {
76
- name : 'tap_horizon_receipts_allocation_id_idx ' ,
89
+ queryInterface . addIndex ( 'tap_horizon_receipts' , [ 'collection_id ' ] , {
90
+ name : 'tap_horizon_receipts_collection_id_idx ' ,
77
91
} )
78
92
queryInterface . addIndex ( 'tap_horizon_receipts' , [ 'timestamp_ns' ] , {
79
93
name : 'tap_horizon_receipts_timestamp_ns_idx' ,
@@ -91,18 +105,32 @@ export async function up({ context }: Context): Promise<void> {
91
105
primaryKey : true ,
92
106
autoIncrement : true ,
93
107
} ,
94
- allocation_id : {
95
- type : DataTypes . CHAR ( 40 ) ,
96
- allowNull : false ,
97
- } ,
98
108
signer_address : {
99
109
type : DataTypes . CHAR ( 40 ) ,
100
110
allowNull : false ,
101
111
} ,
112
+
113
+ // Values below are the individual fields of the EIP-712 receipt
102
114
signature : {
103
115
type : DataTypes . BLOB ,
104
116
allowNull : false ,
105
117
} ,
118
+ collection_id : {
119
+ type : DataTypes . CHAR ( 64 ) ,
120
+ allowNull : false ,
121
+ } ,
122
+ payer : {
123
+ type : DataTypes . CHAR ( 40 ) ,
124
+ allowNull : false ,
125
+ } ,
126
+ data_service : {
127
+ type : DataTypes . CHAR ( 40 ) ,
128
+ allowNull : false ,
129
+ } ,
130
+ service_provider : {
131
+ type : DataTypes . CHAR ( 40 ) ,
132
+ allowNull : false ,
133
+ } ,
106
134
timestamp_ns : {
107
135
type : DataTypes . DECIMAL ( 20 ) ,
108
136
allowNull : false ,
@@ -115,6 +143,10 @@ export async function up({ context }: Context): Promise<void> {
115
143
type : DataTypes . DECIMAL ( 20 ) ,
116
144
allowNull : false ,
117
145
} ,
146
+ error_log : {
147
+ type : DataTypes . TEXT ,
148
+ allowNull : true ,
149
+ } ,
118
150
} )
119
151
}
120
152
@@ -123,28 +155,29 @@ export async function up({ context }: Context): Promise<void> {
123
155
} else {
124
156
// Create the tap_horizon_ravs table if it doesn't exist
125
157
await queryInterface . createTable ( 'tap_horizon_ravs' , {
158
+ // Values below are the individual fields of the EIP-712 receipt
159
+ signature : {
160
+ type : DataTypes . BLOB ,
161
+ allowNull : false ,
162
+ } ,
126
163
collection_id : {
127
164
type : DataTypes . CHAR ( 64 ) ,
128
165
allowNull : false ,
129
166
} ,
130
- sender_address : {
167
+ payer : {
131
168
type : DataTypes . CHAR ( 40 ) ,
132
169
allowNull : false ,
133
170
} ,
134
- service_provider_address : {
171
+ data_service : {
135
172
type : DataTypes . CHAR ( 40 ) ,
136
173
allowNull : false ,
137
174
} ,
138
- data_service_address : {
175
+ service_provider : {
139
176
type : DataTypes . CHAR ( 40 ) ,
140
177
allowNull : false ,
141
178
} ,
142
- signature : {
143
- type : DataTypes . BLOB ,
144
- allowNull : false ,
145
- } ,
146
179
timestamp_ns : {
147
- type : DataTypes . DECIMAL ,
180
+ type : DataTypes . DECIMAL ( 20 ) ,
148
181
allowNull : false ,
149
182
} ,
150
183
value_aggregate : {
@@ -155,16 +188,18 @@ export async function up({ context }: Context): Promise<void> {
155
188
type : DataTypes . BLOB ,
156
189
allowNull : false ,
157
190
} ,
158
- final : {
191
+
192
+ last : {
159
193
type : DataTypes . BOOLEAN ,
160
194
allowNull : false ,
161
195
defaultValue : false ,
162
196
} ,
163
- last : {
197
+ final : {
164
198
type : DataTypes . BOOLEAN ,
165
199
allowNull : false ,
166
200
defaultValue : false ,
167
201
} ,
202
+
168
203
redeemed_at : {
169
204
type : DataTypes . DATE ,
170
205
allowNull : true ,
@@ -182,7 +217,7 @@ export async function up({ context }: Context): Promise<void> {
182
217
183
218
logger . info ( `Add primary key` )
184
219
await queryInterface . addConstraint ( 'tap_horizon_ravs' , {
185
- fields : [ 'collection_id ' , 'sender_address ' , 'service_provider_address ' , 'data_service_address ' ] ,
220
+ fields : [ 'payer ' , 'data_service ' , 'service_provider ' , 'collection_id ' ] ,
186
221
type : 'primary key' ,
187
222
name : 'pk_tap_horizon_ravs' ,
188
223
} )
@@ -197,15 +232,15 @@ export async function up({ context }: Context): Promise<void> {
197
232
type : DataTypes . CHAR ( 64 ) ,
198
233
allowNull : false ,
199
234
} ,
200
- sender_address : {
235
+ payer : {
201
236
type : DataTypes . CHAR ( 40 ) ,
202
237
allowNull : false ,
203
238
} ,
204
- service_provider_address : {
239
+ data_service : {
205
240
type : DataTypes . CHAR ( 40 ) ,
206
241
allowNull : false ,
207
242
} ,
208
- data_service_address : {
243
+ service_provider : {
209
244
type : DataTypes . CHAR ( 40 ) ,
210
245
allowNull : false ,
211
246
} ,
@@ -239,7 +274,7 @@ export async function down({ context }: Context): Promise<void> {
239
274
)
240
275
await queryInterface . removeIndex (
241
276
'tap_horizon_receipts' ,
242
- 'tap_horizon_receipts_allocation_id_idx ' ,
277
+ 'tap_horizon_receipts_collection_id_idx ' ,
243
278
)
244
279
await queryInterface . removeIndex (
245
280
'tap_horizon_receipts' ,
0 commit comments